2626
2727 - name : Checkout the repository
2828 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29- - name : Download ghcommit CLI
30- run : |
31- curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
32- chmod +x /usr/local/bin/ghcommit
33- - name : Pick a branch name
34- id : define-branch
35- run : echo "branch=ci/update-docker-build-image-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
36- - name : Create branch
37- run : |
38- git checkout -b ${{ steps.define-branch.outputs.branch }}
39- git push -u origin ${{ steps.define-branch.outputs.branch }} --force
40- - name : Define the Docker build image tage to use
29+ - name : Define the Docker build image tag to use
4130 id : define-tag
4231 run : |
4332 if [ -n "${{ github.event.inputs.tag }}" ]; then
@@ -59,12 +48,38 @@ jobs:
5948 - name : Update the Docker build image in GitLab CI config
6049 run : |
6150 sed -i -E 's|(BUILDER_IMAGE_VERSION_PREFIX:)[^#]*([#].*)|\1 "${{ steps.define-tag.outputs.tag }}-" \2|' .gitlab-ci.yml
51+ - name : Check if changes should be committed
52+ id : check-changes
53+ run : |
54+ if [[ -z "$(git status -s)" ]]; then
55+ echo "No changes to commit, exiting."
56+ echo "commit_changes=false" >> "$GITHUB_OUTPUT"
57+ exit 0
58+ else
59+ echo "commit_changes=true" >> "$GITHUB_OUTPUT"
60+ fi
61+ - name : Download ghcommit CLI
62+ if : steps.check-changes.outputs.commit_changes == 'true'
63+ run : |
64+ curl https://github.com/planetscale/ghcommit/releases/download/v0.1.48/ghcommit_linux_amd64 -o /usr/local/bin/ghcommit -L
65+ chmod +x /usr/local/bin/ghcommit
66+ - name : Pick a branch name
67+ if : steps.check-changes.outputs.commit_changes == 'true'
68+ id : define-branch
69+ run : echo "branch=ci/update-docker-build-image-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
70+ - name : Create branch
71+ if : steps.check-changes.outputs.commit_changes == 'true'
72+ run : |
73+ git checkout -b ${{ steps.define-branch.outputs.branch }}
74+ git push -u origin ${{ steps.define-branch.outputs.branch }} --force
6275 - name : Commit and push changes
76+ if : steps.check-changes.outputs.commit_changes == 'true'
6377 env :
6478 GITHUB_TOKEN : ${{ steps.octo-sts.outputs.token }}
6579 run : |
6680 ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .gitlab-ci.yml --message "feat(ci): Update Docker build image"
6781 - name : Create pull request
82+ if : steps.check-changes.outputs.commit_changes == 'true'
6883 env :
6984 GH_TOKEN : ${{ steps.octo-sts.outputs.token }}
7085 run : |
0 commit comments