Skip to content

Commit 6c994a5

Browse files
authored
autodeploy PRs (#218)
1 parent de6e82d commit 6c994a5

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/workflows/preview.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,38 @@ env:
66
on:
77
issue_comment:
88
types: [created]
9+
pull_request:
910
jobs:
1011
deploy:
1112
runs-on: ubuntu-latest
1213
# todo skip already created deploys on that commit
1314
if: >-
14-
github.event.issue.pull_request != '' &&
1515
(
16-
contains(github.event.comment.body, '/deploy')
16+
github.event.issue.pull_request != '' &&
17+
(
18+
contains(github.event.comment.body, '/deploy')
19+
)
20+
) ||
21+
(
22+
github.event_name == 'pull_request' && (
23+
env.AUTO_DEPLOY_PRS contains $'\n' + toString(github.event.pull_request.number) + $'\n' ||
24+
startsWith(env.AUTO_DEPLOY_PRS, toString(github.event.pull_request.number) + $'\n') ||
25+
endsWith(env.AUTO_DEPLOY_PRS, $'\n' + toString(github.event.pull_request.number)) ||
26+
env.AUTO_DEPLOY_PRS == toString(github.event.pull_request.number)
27+
)
1728
)
1829
permissions:
1930
pull-requests: write
2031
steps:
21-
- name: Checkout
32+
- name: Checkout PR (comment)
2233
uses: actions/checkout@v2
34+
if: github.event_name == 'issue_comment'
2335
with:
2436
ref: refs/pull/${{ github.event.issue.number }}/head
37+
- name: Checkout PR (pull_request)
38+
uses: actions/checkout@v2
39+
if: github.event_name == 'pull_request'
40+
2541
- run: npm i -g [email protected]
2642
- uses: actions/setup-node@v4
2743
with:
@@ -59,7 +75,7 @@ jobs:
5975
id: alias
6076
env:
6177
ALIASES: ${{ env.ALIASES }}
62-
PULL_URL: ${{ github.event.issue.pull_request.url }}
78+
PULL_URL: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }}
6379
- name: Set deployment alias
6480
if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }}
6581
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro

0 commit comments

Comments
 (0)