26
26
27
27
- name : Checkout the repository
28
28
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
41
30
id : define-tag
42
31
run : |
43
32
if [ -n "${{ github.event.inputs.tag }}" ]; then
@@ -59,12 +48,38 @@ jobs:
59
48
- name : Update the Docker build image in GitLab CI config
60
49
run : |
61
50
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
62
75
- name : Commit and push changes
76
+ if : steps.check-changes.outputs.commit_changes == 'true'
63
77
env :
64
78
GITHUB_TOKEN : ${{ steps.octo-sts.outputs.token }}
65
79
run : |
66
80
ghcommit --repository ${{ github.repository }} --branch ${{ steps.define-branch.outputs.branch }} --add .gitlab-ci.yml --message "feat(ci): Update Docker build image"
67
81
- name : Create pull request
82
+ if : steps.check-changes.outputs.commit_changes == 'true'
68
83
env :
69
84
GH_TOKEN : ${{ steps.octo-sts.outputs.token }}
70
85
run : |
0 commit comments