-
Notifications
You must be signed in to change notification settings - Fork 2.9k
176 lines (161 loc) · 6.98 KB
/
automerge.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Automerge PR
# This workflow is triggered by a pull request that is labeled
on:
pull_request:
types:
- labeled
status: {}
jobs:
getPullRequestMergeability:
if: github.actor == 'OSBotify' && github.event.label.name == 'automerge'
runs-on: ubuntu-latest
outputs:
isMergeable: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE }}
steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if pull request is mergeable
id: isPullRequestMergeable
uses: Expensify/Expensify.cash/.github/actions/isPullRequestMergeable@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
- name: Fail workflow if PR is not mergeable
if: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }}
run: exit 1
# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ failure() }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
main:
runs-on: ubuntu-latest
needs: getPullRequestMergeability
if: github.event.pull_request.base.ref == 'main' && github.actor == 'OSBotify' && github.event.label.name == 'automerge'
steps:
- name: Export Files Changed
id: changed
# Version: 3.3.0
uses: futuratrepadeira/changed-files@1d252c611c64289d35243fc37ece7323ea5e93e1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for an auto approve
# Version: 2.0.0
uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: steps.changed.outputs.files_updated == 'android/app/build.gradle ios/ExpensifyCash/Info.plist ios/ExpensifyCashTests/Info.plist package-lock.json package.json' && steps.changed.outputs.files_created == '' && steps.changed.outputs.files_deleted == ''
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ failure() }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
staging:
runs-on: ubuntu-latest
needs: getPullRequestMergeability
if: github.event.pull_request.base.ref == 'staging' && github.actor == 'OSBotify' && github.event.label.name == 'automerge'
steps:
- name: Check for an auto approve
# Version: 2.0.0
uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.head.ref == 'main'
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ failure() }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
production:
runs-on: ubuntu-latest
needs: getPullRequestMergeability
if: github.event.pull_request.base.ref == 'production' && github.actor == 'OSBotify' && github.event.label.name == 'automerge'
steps:
- name: Check for an auto approve
# Version: 2.0.0
uses: hmarr/auto-approve-action@7782c7e2bdf62b4d79bdcded8332808fd2f179cd
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.head.ref == 'staging'
- name: Check for an auto merge
# Version: 0.12.0
uses: pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
# the other workflows with the same change
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
if: ${{ failure() }}
with:
status: custom
fields: workflow, repo
custom_payload: |
{
channel: '#announce',
attachments: [{
color: "#DB4545",
pretext: `<!here>`,
text: `💥 ${process.env.AS_REPO} failed on ${process.env.AS_WORKFLOW} workflow 💥`,
}]
}
env:
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}