File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ else
33+ echo "ENV_TAG=" >> $GITHUB_ENV
34+ fi
35+ - name : Force update tag
36+ if : ${{ env.ENV_TAG != '' }}
37+ run : |
38+ git config user.name "github-actions[bot]"
39+ git config user.email "github-actions[bot]@users.noreply.github.com"
40+ echo "Targeting tag: ${{ env.ENV_TAG }}"
41+ git tag -f $ENV_TAG
42+ git push origin $ENV_TAG --force
You can’t perform that action at this time.
0 commit comments