First attempt at auto update job
This commit is contained in:
@@ -12,10 +12,16 @@ workflow:
|
||||
when: never
|
||||
# Run reduced pipeline for branches
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
- if: $CI_PIPELINE_SOURCE == "web"
|
||||
|
||||
include:
|
||||
# Low-effort, we can always do lint checks, validations, and so forth
|
||||
- local: .gitlab/always.yml
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE != "web"
|
||||
- local: .gitlab/update.yml
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "web"
|
||||
# Actual download of ISOs and building of images. This should only be
|
||||
# done some of the time
|
||||
- local: .gitlab/build.yml
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user