Skip to content

Commit dfe2d57

Browse files
committed
Create tag.yml
1 parent ddf47b2 commit dfe2d57

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/tag.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Whenever there is a pull request merged into the branches, create tag
2+
name: Update Environment Tag
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- develop
8+
- staging
9+
- production
10+
jobs:
11+
update-tag:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
- name: Get the current branch name
22+
id: get_branch
23+
run: |
24+
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
25+
26+
if [ "$TARGET_BRANCH" = "develop" ]; then
27+
echo "ENV_TAG=dev" >> $GITHUB_ENV
28+
elif [ "$TARGET_BRANCH" = "staging" ]; then
29+
echo "ENV_TAG=stage" >> $GITHUB_ENV
30+
elif [ "$TARGET_BRANCH" = "production" ]; then
31+
echo "ENV_TAG=prod" >> $GITHUB_ENV
32+
fi
33+
- name: Force update tag
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "github-actions[bot]@users.noreply.github.com"
37+
echo "Targeting tag: ${{ env.ENV_TAG }}"
38+
git tag -f $ENV_TAG
39+
git push origin $ENV_TAG --force

0 commit comments

Comments
 (0)