Repository navigation
107 lines (101 loc) · 4.43 KB
/
Copy pathbuild.yml
File metadata and controls
107 lines (101 loc) · 4.43 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
name: build
on:
release:
types: [created]
push:
branches:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/tags/v') && 'release' || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v') }}
env:
# renovate: datasource=npm depName=npm
NPM_VERSION: "11"
# renovate: datasource=npm depName=@microbit-foundation/python-editor-v3-microbit registryUrl=https://npm.pkg.github.com
THEME_VERSION: 0.4.1
jobs:
stages:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.stages.outputs.matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- id: stages
run: node ./bin/print-ci-stages.cjs >> "$GITHUB_OUTPUT"
build:
needs: stages
name: build (${{ matrix.stage }})
strategy:
# Each stage deploys only if its own checks pass.
fail-fast: false
matrix: ${{ fromJSON(needs.stages.outputs.matrix) }}
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
# Deploys assume an AWS role through GitHub OIDC.
id-token: write
env:
STAGE: ${{ matrix.stage }}
AWS_DEFAULT_REGION: eu-west-1
VITE_FOUNDATION_BUILD: ${{ github.repository_owner == 'microbit-foundation' }}
# This feature is also controlled by a client-side feature flag that is disabled by default for the moment
FEATURE_PWA: ${{ github.repository_owner == 'microbit-foundation' }}
steps:
# Note: This workflow disables deployment steps and micro:bit branding installation on forks.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Configure node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 24.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm install -g npm@${{ env.NPM_VERSION }} --registry=https://registry.npmjs.org
- uses: microbit-foundation/npm-package-versioner-action@v3
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm install --no-save @microbit-foundation/python-editor-v3-microbit@${{ env.THEME_VERSION }}
if: github.repository_owner == 'microbit-foundation'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: node ./bin/print-ci-env-stage.cjs >> $GITHUB_ENV
- run: node ./bin/print-ci-env-public-url.cjs >> $GITHUB_ENV
- run: npm run ci
env:
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
# Uploads source maps to Sentry. Review builds don't report to Sentry.
SENTRY_AUTH_TOKEN: ${{ env.STAGE != 'REVIEW' && secrets.SENTRY_AUTH_TOKEN || '' }}
# One stage per ref runs Playwright (bin/print-ci-stages.cjs).
- name: Run Playwright tests
if: matrix.playwright
timeout-minutes: 10
uses: docker://mcr.microsoft.com/playwright:v1.65.0-noble
with:
args: npx playwright test
- name: Store reports
if: matrix.playwright && failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: playwright-report
path: playwright-report/
retention-days: 3
# Review deploys even when tests fail. The buckets, distributions and
# roles are in microbit-foundation/microbit-org's apps/python. Only main
# and release tags can assume the role for staging, beta and production.
- uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6
if: github.repository_owner == 'microbit-foundation' && (env.STAGE == 'REVIEW' && !cancelled() || success())
with:
role-to-assume: arn:aws:iam::700731169244:role/github-actions-deploy-python-content${{ env.STAGE != 'REVIEW' && '-release' || '' }}
aws-region: eu-west-1
- run: npm run deploy
if: github.repository_owner == 'microbit-foundation' && (env.STAGE == 'REVIEW' && !cancelled() || success())
env:
# Set to 1 for one deploy after changing params in deployment.cjs,
# as unchanged files are otherwise skipped.
WEBSITE_DEPLOY_FORCE: 0
- run: npm run invalidate
if: github.repository_owner == 'microbit-foundation' && (env.STAGE == 'REVIEW' && !cancelled() || success())