Skip to content

Commit 193a508

Browse files
authored
[BE] Mark custom terraform module tags as such (#6822)
This allows us to easily tell which terraform tags are custom ones manually created vs which ones were automatically generated by pushes to `main` Goal of this PR is to prevent tags that were manually created but not on `main` from accidentally being deployed to prod It: - Appends "-custom" to any tag that wasn't generated by a push to main - Also triggers the tag creation workflow when someone modifies it, for testing Testing: Generated tags via this PR, updated local Terrafile, ran `make plan` locally and verified terraform module was downloaded successfully
1 parent 5da596f commit 193a508

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/lambda-release-tag-runners.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
paths:
99
- 'terraform-aws-github-runner/**'
10+
pull_request: # Generate tag when PR modifies this workflow file
11+
paths:
12+
- '.github/workflows/lambda-release-tag-runners.yml'
1013

1114
jobs:
1215
tag:
@@ -15,6 +18,7 @@ jobs:
1518
container: node:20
1619
outputs:
1720
date: ${{ steps.date.outputs.date }}
21+
tag_name: ${{ steps.tag.outputs.tag_name }}
1822
steps:
1923
- name: Checkout branch
2024
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -24,18 +28,27 @@ jobs:
2428
run: |
2529
echo "date=$(date +'%Y%m%d-%H%M%S')" >> "${GITHUB_OUTPUT}"
2630
31+
- name: Create tag name
32+
id: tag
33+
run: |
34+
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/main" ]; then
35+
echo "tag_name=v${{ steps.date.outputs.date }}" >> "${GITHUB_OUTPUT}"
36+
else
37+
echo "tag_name=v${{ steps.date.outputs.date }}-custom" >> "${GITHUB_OUTPUT}"
38+
fi
39+
2740
- name: Tag snapshot
2841
uses: tvdias/github-tagger@a570476cc87352c1655c606b29590df6014535e0 # v0.0.1
2942
env:
3043
GITHUB_TOKEN: ${{ secrets.TAG_RELEASE }}
3144
with:
3245
repo-token: ${{ secrets.TAG_RELEASE }}
33-
tag: v${{ steps.date.outputs.date }}
46+
tag: ${{ steps.tag.outputs.tag_name }}
3447

3548
call-release:
3649
permissions:
3750
contents: write
3851
needs: tag
3952
uses: ./.github/workflows/_lambda-do-release-runners.yml
4053
with:
41-
tag: v${{ needs.tag.outputs.date }}
54+
tag: ${{ needs.tag.outputs.tag_name }}

0 commit comments

Comments
 (0)