Skip to content

Commit c05ca5d

Browse files
authored
Merge branch 'main' into feature/25-00-NC-feat-church-invites
2 parents 7246403 + cbb5a44 commit c05ca5d

File tree

1 file changed

+118
-20
lines changed

1 file changed

+118
-20
lines changed

.github/workflows/app-deploy.yml

Lines changed: 118 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ jobs:
4343
- id: set-matrix
4444
name: set matrix app to affected array
4545
run: |
46-
echo "matrix=$(npx ts-node tools/scripts/deploy-apps.ts --projects apps/* --exclude api-*)" >> $GITHUB_OUTPUT
46+
echo "matrix=$(npx ts-node tools/scripts/deploy-apps.ts --projects apps/*)" >> $GITHUB_OUTPUT
4747
cat $GITHUB_OUTPUT
4848
deploy-preview:
49-
name: Deploy Preview and Test
49+
name: Deploy Preview
5050
needs: affected
5151
# if branch is not main or is a pull request
5252
if: |
@@ -74,7 +74,9 @@ jobs:
7474
- app: journeys-admin
7575
github-ref-name: stage
7676
github-event-name: push
77-
runs-on: blacksmith-4vcpu-ubuntu-2204
77+
runs-on: blacksmith-2vcpu-ubuntu-2204
78+
env:
79+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
7880
outputs:
7981
url: ${{ steps.deployment-url.outputs.deployment-url }}
8082
permissions:
@@ -107,11 +109,6 @@ jobs:
107109
with:
108110
key: ${{ github.repository }}-${{ steps.node-version.outputs.version }}-node-modules
109111
path: ./node_modules
110-
- name: Mount playwright cache
111-
uses: useblacksmith/stickydisk@v1
112-
with:
113-
key: ${{ github.repository }}-playwright-cache
114-
path: ~/.cache/ms-playwright
115112
- name: NPM Install
116113
run: npm install --silent
117114
- uses: nrwl/nx-set-shas@v4
@@ -174,11 +171,123 @@ jobs:
174171
state: ${{ job.status }}
175172
environment-url: ${{ steps.deployment-url.outputs.deployment-url }}
176173
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
174+
- name: Prepare E2E input file
175+
run: |
176+
mkdir -p e2e-input
177+
echo "${{ steps.deployment-url.outputs.deployment-url }}" > e2e-input/${{ matrix.app }}.txt
178+
- name: Upload E2E input artifact
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: e2e-input-${{ matrix.app }}
182+
path: e2e-input/${{ matrix.app }}.txt
183+
if-no-files-found: ignore
184+
overwrite: true
185+
retention-days: 2
186+
deploy-status:
187+
runs-on: blacksmith-2vcpu-ubuntu-2204
188+
needs: [affected, deploy-preview]
189+
if: ${{ always() && github.event_name == 'pull_request' }}
190+
steps:
191+
- name: Successful deploy
192+
if: ${{ !(contains(needs.*.result, 'failure')) }}
193+
run: exit 0
194+
- name: Failing deploy
195+
if: ${{ contains(needs.*.result, 'failure') }}
196+
run: exit 1
197+
build-e2e-matrix:
198+
name: Build E2E Matrix
199+
needs: [affected, deploy-preview]
200+
if: ${{ needs.deploy-preview.result == 'success' }}
201+
permissions:
202+
actions: read
203+
contents: read
204+
runs-on: blacksmith-2vcpu-ubuntu-2204
205+
outputs:
206+
include: ${{ steps.build.outputs.include }}
207+
apps: ${{ steps.build.outputs.apps }}
208+
steps:
209+
- name: Download all E2E input artifacts
210+
uses: actions/download-artifact@v4
211+
with:
212+
path: e2e-input
213+
pattern: e2e-input-*
214+
merge-multiple: true
215+
- name: Build matrix from deployments
216+
id: build
217+
run: |
218+
set -euo pipefail
219+
include='[]'
220+
if [ ! -d e2e-input ]; then
221+
echo "include=${include}" >> $GITHUB_OUTPUT
222+
echo "apps=[]" >> $GITHUB_OUTPUT
223+
exit 0
224+
fi
225+
shopt -s nullglob
226+
files=(e2e-input/*.txt)
227+
echo "E2E input files found: ${files[*]:-none}"
228+
if [ ${#files[@]} -eq 0 ]; then
229+
echo "include=${include}" >> $GITHUB_OUTPUT
230+
echo "apps=[]" >> $GITHUB_OUTPUT
231+
exit 0
232+
fi
233+
for f in "${files[@]}"; do
234+
app=$(basename "${f}" .txt)
235+
url=$(cat "${f}")
236+
echo "Adding app=${app} url=${url}"
237+
if [ -n "${url}" ]; then
238+
include=$(jq -c --arg app "${app}" --arg url "${url}" '. + [{app:$app, url:$url}]' <<<"${include}")
239+
fi
240+
done
241+
apps=$(jq -c '[.[] | .app]' <<<"${include}")
242+
echo "Final E2E include: ${include}"
243+
echo "include=${include}" >> $GITHUB_OUTPUT
244+
echo "apps=${apps}" >> $GITHUB_OUTPUT
245+
e2e:
246+
name: Playwright E2E (${{ matrix.app }})
247+
needs: [build-e2e-matrix]
248+
# Only run if ALL deploy-preview matrix entries succeeded and we have URLs
249+
if: ${{ needs.build-e2e-matrix.result == 'success' && needs.build-e2e-matrix.outputs.apps != '[]' && needs.build-e2e-matrix.outputs.apps != '' }}
250+
permissions:
251+
contents: read
252+
runs-on: blacksmith-4vcpu-ubuntu-2204
253+
env:
254+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
255+
strategy:
256+
fail-fast: false
257+
matrix:
258+
app: ${{ fromJson(needs.build-e2e-matrix.outputs.apps) }}
259+
node-version: [22]
260+
include: ${{ fromJson(needs.build-e2e-matrix.outputs.include) }}
261+
steps:
262+
- uses: actions/checkout@v4
263+
- uses: useblacksmith/setup-node@v5
264+
with:
265+
node-version: ${{ matrix.node-version }}
266+
- name: Mount playwright cache
267+
uses: useblacksmith/stickydisk@v1
268+
with:
269+
key: ${{ github.repository }}-playwright-cache
270+
path: ~/.cache/ms-playwright
271+
- name: Get Node Version
272+
id: node-version
273+
run: echo "version=$(node -v)" >> $GITHUB_OUTPUT
274+
- name: Mount NPM Cache
275+
uses: useblacksmith/stickydisk@v1
276+
with:
277+
key: ${{ github.repository }}-${{ steps.node-version.outputs.version }}-npm-cache
278+
path: ~/.npm
279+
- name: Mount node_modules
280+
uses: useblacksmith/stickydisk@v1
281+
with:
282+
key: ${{ github.repository }}-${{ steps.node-version.outputs.version }}-node-modules
283+
path: ./node_modules
284+
- name: NPM Install
285+
run: npm install --silent
177286
- run: npx playwright install --with-deps
178287
- name: Run Playwright tests
179288
run: npx nx run ${{ matrix.app }}-e2e:e2e
180289
env:
181-
DEPLOYMENT_URL: ${{ steps.deployment-url.outputs.deployment-url }}
290+
DEPLOYMENT_URL: ${{ matrix.url }}
182291
PLAYWRIGHT_USER: ${{ secrets.PLAYWRIGHT_USER }}
183292
PLAYWRIGHT_TEAM_NAME: ${{ secrets.PLAYWRIGHT_TEAM_NAME }}
184293
EXAMPLE_EMAIL_TOKEN: ${{ secrets.EXAMPLE_EMAIL_TOKEN }}
@@ -199,17 +308,6 @@ jobs:
199308
path: |
200309
playwright-report/
201310
retention-days: 30
202-
deploy-status:
203-
runs-on: blacksmith-2vcpu-ubuntu-2204
204-
needs: [affected, deploy-preview]
205-
if: ${{ always() && github.event_name == 'pull_request' }}
206-
steps:
207-
- name: Successful deploy
208-
if: ${{ !(contains(needs.*.result, 'failure')) }}
209-
run: exit 0
210-
- name: Failing deploy
211-
if: ${{ contains(needs.*.result, 'failure') }}
212-
run: exit 1
213311
deploy-production:
214312
name: Deploy Production
215313
# if push to main or stage

0 commit comments

Comments
 (0)