File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ name : Update Tekton Tags
3+ on : # yamllint disable-line rule:truthy
4+ workflow_dispatch :
5+ inputs :
6+ new_tag :
7+ description : " Set a new image tag (e.g. YYYYx-vn.n)"
8+ required : true
9+ jobs :
10+ update-tags :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : write
14+ steps :
15+ - name : Checkout repo
16+ uses : actions/checkout@v5
17+ with :
18+ ref : main
19+ fetch-depth : 0
20+
21+ - name : Detect and replace tag in .tekton yamls
22+ id : replace
23+ run : |
24+ set -e
25+ regex="[0-9]{4}[a-z]-v[0-9]+\.[0-9]+"
26+ new_tag="${{ github.event.inputs.new_tag }}"
27+
28+ echo "Searching for tags in .tekton/*.yaml..."
29+ prev_tag=$(grep -rhoP "$regex" .tekton/*.yaml | sort -u | head -n1)
30+
31+ if [ -z "$prev_tag" ]; then
32+ echo "❌ No matching tag found with regex $regex"
33+ exit 1
34+ fi
35+
36+ echo "Found previous tag: $prev_tag"
37+ echo "Replacing $prev_tag -> $new_tag"
38+
39+ find .tekton -type f -name "*.yaml" -print0 | xargs -0 -I{} perl -0777 -i -pe "s/\Q$prev_tag\E/\Q$new_tag\E/g" "{}"
40+
41+ # Export previous tag for later steps
42+ echo "previous_tag=$prev_tag" >> $GITHUB_OUTPUT
43+
44+ - name : Commit and push changes
45+ run : |
46+ prev_tag="${{ steps.replace.outputs.previous_tag }}"
47+ new_tag="${{ github.event.inputs.new_tag }}"
48+
49+ git config user.name "github-actions[bot]"
50+ git config user.email "github-actions[bot]@users.noreply.github.com"
51+
52+ if git diff --quiet; then
53+ echo "✅ No changes to commit"
54+ exit 0
55+ fi
56+
57+ git add .tekton/*.yaml
58+ git commit -m "chore: update tekton tag from ${prev_tag} to ${new_tag}"
59+ git push origin main
You can’t perform that action at this time.
0 commit comments