|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "**" |
| 9 | + |
| 10 | +# This is conservative: ideally we'd include branch and stage in this key |
| 11 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency |
| 12 | +concurrency: deploy-python-editor-v3 |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + packages: read |
| 20 | + env: |
| 21 | + AWS_DEFAULT_REGION: eu-west-1 |
| 22 | + PRODUCTION_CLOUDFRONT_DISTRIBUTION_ID: E2ELTBTA2OFPY2 |
| 23 | + STAGING_CLOUDFRONT_DISTRIBUTION_ID: E2ELTBTA2OFPY2 |
| 24 | + REVIEW_CLOUDFRONT_DISTRIBUTION_ID: E3267W09ZJHQG9 |
| 25 | + |
| 26 | + steps: |
| 27 | + # Note: This workflow will not run on forks without modification; we're open to making steps |
| 28 | + # that reply on our deployment infrastructure conditional. Please open an issue. |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + - name: Configure node |
| 31 | + uses: actions/setup-node@v3 |
| 32 | + with: |
| 33 | + node-version: 16.x |
| 34 | + cache: "npm" |
| 35 | + registry-url: "https://npm.pkg.github.com" |
| 36 | + - run: npm ci |
| 37 | + env: |
| 38 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + - run: npm install --no-save @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/[email protected] @microbit-foundation/circleci-npm-package-versioner@1 |
| 40 | + env: |
| 41 | + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + - run: node ./bin/print-ci-env.js >> $GITHUB_ENV |
| 43 | + - run: npm run ci:update-version |
| 44 | + - run: npm run ci |
| 45 | + - run: mkdir -p /tmp/app${PUBLIC_URL} && cp -r build/* /tmp/app${PUBLIC_URL} && npx serve --no-clipboard -l 3000 /tmp/app & |
| 46 | + if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING' |
| 47 | + - run: curl --insecure -4 --retry 7 --retry-connrefused http://localhost:3000 1>/dev/null |
| 48 | + if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING' |
| 49 | + - run: npm run test:e2e:headless |
| 50 | + if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING' |
| 51 | + - name: Store reports |
| 52 | + if: env.STAGE == 'REVIEW' || env.STAGE == 'STAGING' |
| 53 | + uses: actions/upload-artifact@v3 |
| 54 | + with: |
| 55 | + name: reports |
| 56 | + path: reports/ |
| 57 | + - run: npm run deploy |
| 58 | + env: |
| 59 | + AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }} |
| 60 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }} |
| 61 | + - run: npm run invalidate |
| 62 | + env: |
| 63 | + AWS_ACCESS_KEY_ID: ${{ secrets.WEB_DEPLOY_AWS_ACCESS_KEY_ID }} |
| 64 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.WEB_DEPLOY_AWS_SECRET_ACCESS_KEY }} |
0 commit comments