58 lines
1.8 KiB
YAML
58 lines
1.8 KiB
YAML
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#* }
|
|
# Auto-merge through the REST API throws an error, and I can't get it to work through the
|
|
# GraphQL API either. There it doesn't return an error, but the auto-merge does not happen
|
|
#- >-
|
|
#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"
|