File tree 1 file changed +26
-2
lines changed
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 4
4
pull_request :
5
5
types :
6
6
- labeled
7
+ workflow_dispatch :
8
+ inputs :
9
+ branch :
10
+ description : ' Branch to build and release'
11
+ required : true
12
+ default : ' main'
13
+ release_name :
14
+ description : ' Release name to publish to npm'
15
+ required : true
16
+ default : ' experimental'
7
17
8
18
jobs :
9
19
publish :
10
- if : ${{ github.event.label.name == 'build' }}
11
20
runs-on : ubuntu-latest
12
21
steps :
22
+ - name : Validate label name
23
+ if : ${{ github.event_name == 'pull_request' && github.event.label.name == 'build' }}
24
+ run : echo "Label is 'build', proceeding with the workflow."
25
+
26
+ - name : Check for open pull request
27
+ if : ${{ github.event_name == 'workflow_dispatch' }}
28
+ id : check_pr
29
+ run : |
30
+ PR_DATA=$(gh pr list --state open --head ${{ inputs.branch }} --json number --jq '.[0]')
31
+ if [ -z "$PR_DATA" ]; then
32
+ echo "No open pull request found for branch ${{ inputs.branch }}."
33
+ exit 1
34
+ fi
35
+ echo "PR_NUMBER=$(echo $PR_DATA | jq -r '.number')" >> $GITHUB_ENV
36
+
13
37
- uses : actions/checkout@v3
14
38
with :
15
39
ref : ${{ github.event.pull_request.head.sha }}
20
44
registry-url : ' https://registry.npmjs.org'
21
45
# Ensure that the README is published with the package
22
46
- run : rm -f packages/cli/README.md && cp README.md packages/cli
23
- - run : echo "PR_VERSION=0.0.0-pr.${{github.event.pull_request.number}}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
47
+ - run : echo "PR_VERSION=${{ github.event_name == 'workflow_dispatch' && inputs.release_name || ' 0.0.0-pr.${{github.event.pull_request.number}}' .$(git rev-parse --short HEAD)}} " >> $GITHUB_ENV
24
48
- run : npm ci
25
49
- run : npm version ${{ env.PR_VERSION }} --workspace packages/cli
26
50
- run : npm publish --workspace packages/cli --tag experimental
You can’t perform that action at this time.
0 commit comments