forked from microbit-foundation/python-editor-v3
-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (79 loc) · 3.41 KB
/
build.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
name: build
on:
workflow_dispatch:
release:
types: [created]
repository_dispatch:
types: [new_theme_released]
push:
branches:
- "feature/*"
- "main"
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') }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
env:
AWS_DEFAULT_REGION: eu-west-1
steps:
# Note: This workflow disables deployment steps and micro:bit branding installation on forks.
- uses: actions/checkout@v3
- name: Configure node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
scope: "@calliope-edu"
- run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm install --no-save @calliope-edu/calliope-theme @calliope-edu/website-deploy-aws-config #@microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1
if: github.repository_owner == 'calliope-edu'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: node ./bin/print-ci-env-stage.js >> $GITHUB_ENV
- run: node ./bin/print-ci-env-public-url.js >> $GITHUB_ENV
# - run: npm run ci:update-version
# if: github.repository_owner == 'calliope-edu'
- run: npm run build
if: github.repository_owner == 'calliope-edu'
# env:
# REACT_APP_GA_MEASUREMENT_ID: ${{ secrets.GA_MEASUREMENT_ID }}
# REACT_APP_GA_COOKIE_PREFIX: ${{ secrets.REACT_APP_GA_COOKIE_PREFIX }}
- run: mkdir -p /tmp/app${PUBLIC_URL} && cp -r build/* /tmp/app${PUBLIC_URL} && npx serve --no-clipboard -l 3000 /tmp/app &
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- run: curl --insecure -4 --retry 7 --retry-connrefused http://localhost:3000 1>/dev/null
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- run: npm run test:e2e:headless
if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING'
- name: Store reports
if: (env.STAGE == 'REVIEW' || env.STAGE == 'STAGING') && failure()
uses: actions/upload-artifact@v3
with:
name: reports
path: reports/
- name: Deploy static site to S3 bucket
run: aws s3 sync ./build/ s3://${{ env.DEPLOY_PATH }} --delete
if: github.repository_owner == 'calliope-edu' && (env.STAGE == 'REVIEW' || success())
env:
AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }}
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ env.DISTRIBUTION_ID }}
PATHS: "/*"
AWS_REGION: "eu-central-1"
AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }}
# - run: npm run invalidate
# if: github.repository_owner == 'calliope-edu' && (env.STAGE == 'REVIEW' || success())
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }}