First attempt at auto update job

This commit is contained in:
Greg Hellings
2025-08-19 20:28:22 -05:00
parent 88e74c95ed
commit ec0b87cee7
2 changed files with 61 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
version_update:
stage: generate
image: "alpine/git:latest"
artifacts:
reports:
dotenv: update.env
script:
- |-
set -x
shopt -s globstar
for updater in distros/**/update.sh; do
bash "$updater"
done
- |-
if git diff --quiet; then
echo "No changes necessary"
else
echo "Found updates to make"
git checkout -b "autoupdate/$CI_PIPELINE_IID"
echo "BRANCH=autoupdate/$CI_PIPELINE_IID" >> update.env
git config set user.name "Greg Hellings - automation"
git config set user.email "greg@thehellings.com"
git stage .
git commit -m "Automatic update $CI_PIPEILNE_IID"
git push "https://${GITLAB_USER_LOGIN}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" HEAD
fi
create_pr:
image:
name: registry.gitlab.com/python-gitlab/python-gitlab:latest
entrypoint: [ '' ]
stage: trigger
needs:
- version_update
dependencies:
- version_update
variables:
GIT_STRATEGY: none
GITLAB_PRIVATE_TOKEN: $CI_GIT_TOKEN
script:
- test -z ${DO_UPDATE} && { echo "No updates required. Not creating PR"; exit 0; }
- >-
CREATE_MR=$(gitlab project-merge-request create
--remote-source-branch true
--project-id ${CI_PROJECT_ID}
--source-branch "${BRANCH}"
--target-branch "main"
--title "Update ISO checksums"
- IID=${CREATE_MR#* }
- >-
gitlab project-merge-request merge
--project-id ${CI_PROJECT_ID}
--iid ${IID}
--merge-when-pipeline-succeeds true
- echo "PR set to auto-merge if build succeeds"