56 lines
1.5 KiB
YAML
56 lines
1.5 KiB
YAML
stages:
|
|
- update
|
|
- merge
|
|
|
|
version_update:
|
|
stage: update
|
|
tags:
|
|
- nix
|
|
artifacts:
|
|
reports:
|
|
dotenv: update.env
|
|
script:
|
|
- nix run ".#update" > update.env
|
|
- |-
|
|
if git diff --quiet; then
|
|
echo "No changes necessary"
|
|
else
|
|
echo "Found changes to make"
|
|
git checkout -b "sword-rev/$CI_PIPELINE_IID"
|
|
echo "BRANCH=sword-rev/$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_PIPELINE_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: merge
|
|
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 crating PR"; exit 0; }
|
|
- >-
|
|
CREATE_MR=$(gitlab project-merge-request create
|
|
--remove-source-branch true
|
|
--project-id ${CI_PROJECT_ID}
|
|
--source-branch "${BRANCfh}"
|
|
--target-branch "main"
|
|
--title "Update sword to r$NEW_REV")
|
|
- 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"
|