4
4
# 3. when a PR is updated
5
5
name : Deploy PR
6
6
on :
7
- pull_request :
8
- types : synchronize
7
+ push :
9
8
workflow_dispatch :
10
9
inputs :
11
10
pr_number :
@@ -37,12 +36,30 @@ permissions:
37
36
pull-requests : write
38
37
39
38
concurrency :
40
- group : ${{ github.workflow }}-PR- ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
39
+ group : ${{ github.workflow }}-${{ github.ref }}
41
40
cancel-in-progress : true
42
41
43
42
jobs :
43
+ check_pr :
44
+ runs-on : ubuntu-latest
45
+ outputs :
46
+ PR_OPEN : ${{ steps.check_pr.outputs.pr_open }}
47
+ steps :
48
+ - name : Check if PR is open
49
+ id : check_pr
50
+ run : |
51
+ set -euo pipefail
52
+ if [[ $(gh pr view --json state | jq -r '.state') != "OPEN" ]]; then
53
+ echo "a PR is not open. skipping"
54
+ pr_open=$(gh pr view --json state | jq -r '.state' != "OPEN")
55
+ fi
56
+ echo "pr_open=$pr_open" >> $GITHUB_OUTPUT
57
+ env :
58
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59
+
44
60
get_info :
45
- if : github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
61
+ needs : check_pr
62
+ if : ${{ needs.check_pr.outputs.PR_OPEN == 'true' }}
46
63
outputs :
47
64
PR_NUMBER : ${{ steps.pr_info.outputs.PR_NUMBER }}
48
65
PR_TITLE : ${{ steps.pr_info.outputs.PR_TITLE }}
@@ -59,13 +76,16 @@ jobs:
59
76
id : pr_info
60
77
run : |
61
78
set -euo pipefail
62
- PR_NUMBER=${{ github.event.inputs.pr_number || github.event.pull_request. number }}
63
- PR_TITLE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.title')
64
- PR_BRANCH =$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER | jq -r '.head.ref ')
65
- echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER " >> $GITHUB_OUTPUT
79
+ PR_NUMBER=$(gh pr view --json number | jq -r '. number')
80
+ PR_TITLE=$(gh pr view --json title | jq -r '.title')
81
+ PR_URL =$(gh pr view --json url | jq -r '.url ')
82
+ echo "PR_URL=$PR_URL " >> $GITHUB_OUTPUT
66
83
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
67
84
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
68
85
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_OUTPUT
86
+ env :
87
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
88
+ PR_BRANCH : ${{ github.ref }}
69
89
70
90
- name : Set required tags
71
91
id : set_tags
@@ -134,6 +154,7 @@ jobs:
134
154
uses : dorny/paths-filter@v2
135
155
id : filter
136
156
with :
157
+ base : ${{ steps.pr_info.outputs.PR_BRANCH }}
137
158
filters : |
138
159
all:
139
160
- "**"
0 commit comments