11name : Staging Release
22
3- on : workflow_dispatch
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ release-branch :
7+ description : ' Release branch'
8+ type : string
9+ default : ' release'
10+ required : true
11+ source-branch :
12+ description : ' Branch to release from'
13+ type : choice
14+ default : ' master'
15+ required : true
16+ options :
17+ - master
18+ - v8
419
520jobs :
6- warn :
7- name : Warn If Wrong Branch
8- runs-on : ubuntu-latest
9- # Log a warning if run in a non-release branch.
10- if : github.ref != 'refs/heads/release' && !endsWith(github.ref, '-releasebranch')
11- steps :
12- - name : Log warning
13- run : echo "This workflow must be run in a release branch. It is being run in ${{ github.ref }}."
1421 deploy :
1522 name : Staging Release
1623 runs-on : ubuntu-latest
17- # Block this workflow if run in a non-release branch.
18- if : github.ref == 'refs/heads/release' || endsWith(github.ref, '-releasebranch')
19- # Allow GITHUB_TOKEN to have write permissions
20- permissions :
21- contents : write
22-
24+ # Block this workflow if run on a non-release branch.
25+ if : github.event.inputs.release-branch == 'release' || endsWith(github.event.inputs.release-branch, '-releasebranch')
2326 steps :
2427 - name : Set up Node (14)
2528 uses : actions/setup-node@v2
@@ -28,20 +31,21 @@ jobs:
2831 - name : Merge master into release
2932 uses : actions/github-script@v6
3033 with :
31- github-token : ${{ secrets.GITHUB_TOKEN }}
34+ github-token : ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
3235 script : |
33- let branch = context.ref.replace("refs/heads/", "")
34- await github.rest.repos.merge({
36+ const result = await github.rest.repos.merge({
3537 owner: context.repo.owner,
3638 repo: context.repo.repo,
37- base: branch,
38- head: 'master '
39+ base: '${{ github.event.inputs.release- branch }}' ,
40+ head: '${{ github.event.inputs.source-branch }} '
3941 })
42+ console.log(result)
4043 - name : Checkout current branch (with history)
4144 uses : actions/checkout@master
4245 with :
4346 # Release script requires git history and tags.
4447 fetch-depth : 0
48+ ref : ${{ github.event.inputs.release-branch }}
4549 - name : Yarn install
4650 run : yarn
4751 - name : Publish to NPM
0 commit comments