-
Notifications
You must be signed in to change notification settings - Fork 107
191 lines (172 loc) · 6.15 KB
/
pull-request.yml
File metadata and controls
191 lines (172 loc) · 6.15 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Pull Request
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch:
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
NODE_ENV: production
WRANGLER_SEND_METRICS: false
NODE_OPTIONS: '--disable-warning=ExperimentalWarning --disable-warning=DeprecationWarning'
jobs:
check-membership:
name: Check Org Membership
runs-on: ${{ vars.DEPOT_ENABLED == 'true' && 'depot-ubuntu-latest' || 'ubuntu-latest' }}
outputs:
is-member: ${{ steps.check.outputs.is-member }}
steps:
- name: Check if PR author is org member
id: check
env:
EVENT_NAME: ${{ github.event_name }}
AUTHOR_ASSOCIATION: ${{ github.event.pull_request.author_association }}
run: |
if [[ "$EVENT_NAME" != "pull_request" ]]; then
echo "is-member=true" >> $GITHUB_OUTPUT
exit 0
fi
if [[ "$AUTHOR_ASSOCIATION" == "MEMBER" || "$AUTHOR_ASSOCIATION" == "OWNER" || "$AUTHOR_ASSOCIATION" == "COLLABORATOR" ]]; then
echo "is-member=true" >> $GITHUB_OUTPUT
else
echo "is-member=false" >> $GITHUB_OUTPUT
fi
verify:
name: Verify
uses: ./.github/workflows/verify.yml
deploy-preview:
name: Deploy Preview (${{ matrix.app }}${{ matrix.env && format('-{0}', matrix.env) || '' }})
needs: check-membership
if: needs.check-membership.outputs.is-member == 'true'
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
pull-requests: write
strategy:
matrix:
include:
#### explorer
- app: explorer
env: testnet
- app: explorer
env: devnet
- app: explorer
env: mainnet
#### fee-payer
- app: fee-payer
env: privy
- app: fee-payer
env: devnet
- app: fee-payer
env: moderato
#### other (single-env-apps)
- app: og
- app: perf
- app: tokenlist
env:
NODE_ENV: production
CLOUDFLARE_ENV: ${{ matrix.env || '' }}
steps:
- name: Clone repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
submodules: "recursive"
fetch-depth: 0
persist-credentials: false
# deploy workspace preview only if there are relevant changes
# deploy all apps if root lockfile is changed
- name: Check for relevant changes
id: changes
env:
BASE_REF: ${{ github.base_ref }}
APP_NAME: ${{ matrix.app }}
run: |
if git diff --name-only "origin/${BASE_REF}...HEAD" | grep -qE "^(apps/${APP_NAME}/|pnpm-lock.yaml)"; then
echo "relevant=true" >> $GITHUB_OUTPUT
else
echo "relevant=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.changes.outputs.relevant == 'true'
uses: ./.github/actions/install-dependencies
- name: Generate Worker types
if: steps.changes.outputs.relevant == 'true'
run: pnpm gen:types
working-directory: apps/${{ matrix.app }}
- name: Build
if: steps.changes.outputs.relevant == 'true'
run: pnpm build
working-directory: apps/${{ matrix.app }}
- name: Upload Worker Version
if: steps.changes.outputs.relevant == 'true'
id: deploy
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/${{ matrix.app }}
environment: ${{ env.CLOUDFLARE_ENV }}
command: versions upload
- name: Save Deployment Info
if: always()
shell: bash
run: |
mkdir -p deployment-info
if [[ "${{ steps.changes.outputs.relevant }}" != "true" ]]; then
STATUS="skipped"
DEPLOYMENT_URL=""
ALIAS_URL=""
elif [[ "${{ steps.deploy.outcome }}" == "success" ]]; then
STATUS="success"
DEPLOYMENT_URL="${{ steps.deploy.outputs.deployment-url }}"
ALIAS_URL="${{ steps.deploy.outputs.pages-deployment-alias-url }}"
else
STATUS="failed"
DEPLOYMENT_URL=""
ALIAS_URL=""
fi
FILENAME="deployment-info/${{ matrix.app }}${{ matrix.env && format('-{0}', matrix.env) || '' }}.json"
cat > "$FILENAME" << EOF
{
"app": "${{ matrix.app }}",
"env": "${{ matrix.env }}",
"status": "$STATUS",
"deployment_url": "$DEPLOYMENT_URL",
"deployment_alias_url": "$ALIAS_URL"
}
EOF
cat "$FILENAME"
- name: Upload Deployment Info
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: deployment-${{ matrix.app }}${{ matrix.env && format('-{0}', matrix.env) || '' }}
path: deployment-info/${{ matrix.app }}${{ matrix.env && format('-{0}', matrix.env) || '' }}.json
retention-days: 1
comment-deployments:
name: Post Deployment Table
runs-on: ${{ vars.DEPOT_ENABLED == 'true' && 'depot-ubuntu-latest' || 'ubuntu-latest' }}
needs: [check-membership, deploy-preview]
if: always() && needs.check-membership.outputs.is-member == 'true'
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Download All Deployment Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
pattern: deployment-*
path: deployments
merge-multiple: true
- name: Post Deployment Table
uses: ./.github/actions/post-deployment-table
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
deployments-path: deployments