@@ -13,15 +13,25 @@ concurrency:
1313env :
1414 MAJOR_BRANCH : v1
1515
16+ permissions :
17+ actions : read
18+
1619jobs :
1720 release :
18- runs-on : ubuntu-latest
1921 # Only run this if it's a workflow_dispatch trigger or the CI workflow was successful
2022 if : ${{ github.event.workflow_run == null || github.event.workflow_run.conclusion == 'success' }}
23+
24+ runs-on : ubuntu-latest
25+
26+ # This environment contains secrets needed for publishing
27+ environment : release
28+
2129 steps :
2230 - uses : actions/checkout@v3
2331 with :
2432 fetch-depth : 0
33+ # Don't save creds in the git config (so it's easier to override later)
34+ persist-credentials : false
2535
2636 - name : Set up Node
2737 uses : actions/setup-node@v3
@@ -46,19 +56,30 @@ jobs:
4656 if : ${{ steps.shouldRelease.outputs.shouldRelease == 'yes' }}
4757 run : |
4858 set -x
49- git config user.name "GitHub Workflow"
59+
60+ # Get the existing remote URL without creds, and use a trap (like try/finally)
61+ # to restore it after this step finishes
62+ trap "git remote set-url origin '$(git remote get-url origin)'" EXIT
63+
64+ # Add a token to the remote URL for auth during release
65+ git remote set-url origin "https://[email protected] /$GITHUB_REPOSITORY" 66+
67+ git config user.name "GitHub Actions"
5068 git config user.email "not provided"
51- git checkout $MAJOR_BRANCH
69+
70+ git checkout "$MAJOR_BRANCH"
5271 git merge main --no-edit -Xtheirs
5372 git push origin main
73+ env :
74+ REPO_PAT : ${{ secrets.REPO_PAT }}
5475
5576 - name : Release from ${{ env.MAJOR_BRANCH }}
5677 if : ${{ steps.shouldRelease.outputs.shouldRelease == 'yes' }}
5778 run : |
5879 set -x
5980 yarn check-token "$GH_TOKEN"
60- GITHUB_REF=refs/heads/$MAJOR_BRANCH yarn release
81+ GITHUB_REF=" refs/heads/$MAJOR_BRANCH" yarn release
6182 env :
62- GH_TOKEN : ${{ secrets.TOKEN_RELEASE }}
63- GIT_AUTHOR_NAME : GitHub Workflow
83+ GH_TOKEN : ${{ secrets.REPO_PAT }}
84+ GIT_AUTHOR_NAME : GitHub Actions
6485 GIT_AUTHOR_EMAIL : not provided
0 commit comments