Skip to content

Commit 9a40523

Browse files
ci: change Docker image tags automatically on workflow_call (#36)
1 parent 1ed2ffa commit 9a40523

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: update-docker-image-tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image:
7+
description: 'Docker image name to update'
8+
required: true
9+
type: string
10+
tag:
11+
description: 'New tag for the Docker image'
12+
required: true
13+
type: string
14+
app:
15+
description: 'Specific app/subdirectory to update (optional)'
16+
required: false
17+
type: string
18+
workflow_call:
19+
inputs:
20+
image:
21+
description: 'Docker image name to update'
22+
required: true
23+
type: string
24+
tag:
25+
description: 'New tag for the Docker image'
26+
required: true
27+
type: string
28+
app:
29+
description: 'Specific app/subdirectory to update (optional)'
30+
required: false
31+
type: string
32+
33+
jobs:
34+
update-image-tag:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # SHA for version 5.0.0
40+
41+
- name: Update Docker image tag
42+
working-directory: ./kubernetes
43+
run: |
44+
if [ -n "${{ inputs.app }}" ]; then
45+
make update-image IMAGE="${{ inputs.image }}" TAG="${{ inputs.tag }}" APP="${{ inputs.app }}"
46+
else
47+
make update-image IMAGE="${{ inputs.image }}" TAG="${{ inputs.tag }}"
48+
fi
49+
50+
- name: Check for changes
51+
id: changes
52+
run: |
53+
if [ -n "$(git status --porcelain)" ]; then
54+
echo "has_changes=true" >> $GITHUB_OUTPUT
55+
else
56+
echo "has_changes=false" >> $GITHUB_OUTPUT
57+
fi
58+
59+
- name: Commit and push changes
60+
if: steps.changes.outputs.has_changes == 'true'
61+
run: |
62+
git config --local user.email "action@noreply.github.com"
63+
git config --local user.name "Image Tag Updater"
64+
git add .
65+
git commit -m "chore: update ${{ inputs.image }} to tag ${{ inputs.tag }}"
66+
git push
67+
68+
- name: No changes detected
69+
if: steps.changes.outputs.has_changes == 'false'
70+
run: echo "No changes detected for image ${{ inputs.image }} and new tag ${{ inputs.tag }}"

0 commit comments

Comments
 (0)