generated from CatChen/typescript-github-action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (120 loc) · 3.66 KB
/
ship.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Ship
on:
pull_request:
branches: [main]
types:
- labeled
- unlabeled
- edited
- closed
- reopened
- synchronize
- review_requested
- review_request_removed
pull_request_review:
types: [submitted, edited, dismissed]
check_run:
types: [created, rerequested, completed]
check_suite:
types: [completed]
workflow_run:
workflows:
- Build
- Test
- ESLint
- CodeQL
branches-ignore: ['workflows/tests/*']
types: [completed]
concurrency:
group: |-
${{
github.event.pull_request.number ||
github.event.check_run.pull_requests[0].number ||
github.event.check_suite.pull_requests[0].number ||
github.event.workflow_run.pull_requests[0].number ||
github.sha ||
github.ref
}}
jobs:
concurrency-group:
name: Concurrency group
if: ${{ !startsWith(github.head_ref, 'workflows/tests/') }}
runs-on: ubuntu-latest
steps:
- name: Concurrency group
env:
CONCURRENCY_GROUP: |-
${{
github.event.pull_request.number ||
github.event.check_run.pull_requests[0].number ||
github.event.check_suite.pull_requests[0].number ||
github.event.workflow_run.pull_requests[0].number ||
github.sha ||
github.ref
}}
run: |
echo "::notice::Concurrency group is $CONCURRENCY_GROUP"
accept-to-ship:
name: Accept to Ship
needs: [concurrency-group]
if: |-
${{
!startsWith(github.head_ref, 'workflows/tests/') &&
github.base_ref == 'main' ||
github.event.pull_request.base.ref == 'main' ||
contains(github.event.check_run.pull_requests[0].base.ref, 'main') ||
contains(github.event.check_suite.pull_requests[0].base.ref, 'main') ||
contains(github.event.workflow_run.pull_requests[0].base.ref, 'main')
}}
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
outputs:
skipped: ${{ steps.ship.outputs.skipped }}
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: get-github-app-token
with:
app-id: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_ID }}
private-key: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_PRIVATE_KEY }}
- id: ship
uses: ./
with:
github-token: ${{ steps.get-github-app-token.outputs.token }}
merge-method: squash
timeout: 0
pass-to-ship:
name: Pass to Ship
needs: [concurrency-group]
if: |-
${{
!startsWith(github.head_ref, 'workflows/tests/') &&
github.base_ref == 'main' ||
github.event.pull_request.base.ref == 'main' ||
contains(github.event.check_run.pull_requests[0].base.ref, 'main') ||
contains(github.event.check_suite.pull_requests[0].base.ref, 'main') ||
contains(github.event.workflow_run.pull_requests[0].base.ref, 'main')
}}
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
outputs:
skipped: ${{ steps.ship.outputs.skipped }}
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: get-github-app-token
with:
app-id: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_ID }}
private-key: ${{ secrets.ACCEPT_TO_SHIP_BOT_APP_PRIVATE_KEY }}
- id: ship
uses: ./
with:
github-token: ${{ steps.get-github-app-token.outputs.token }}
merge-method: squash
timeout: 0
request-zero-accept-zero: true
custom-hashtag: '#pass2ship'