|
| 1 | +name: Deploy to AWS |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [ published ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + deploy: |
| 9 | + name: Deploy Embed to AWS |
| 10 | + # Only run for embed releases (not embed-react). Tag format: @typeform/embed-v5.8.0 |
| 11 | + if: startsWith(github.event.release.tag_name, '@typeform/embed-v') |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + id-token: write |
| 16 | + steps: |
| 17 | + - name: Check out Git repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.release.tag_name }} |
| 21 | + |
| 22 | + - name: Set up Node.js |
| 23 | + uses: actions/setup-node@v3 |
| 24 | + with: |
| 25 | + node-version: 22 |
| 26 | + |
| 27 | + - name: Get yarn cache |
| 28 | + uses: actions/cache@v4 |
| 29 | + id: yarn-cache |
| 30 | + with: |
| 31 | + path: | |
| 32 | + **/node_modules |
| 33 | + ~/.cache |
| 34 | + key: ${{ runner.os }}-node-22-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }} |
| 35 | + |
| 36 | + - name: Install Node.js dependencies |
| 37 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 38 | + run: yarn install --frozen-lockfile |
| 39 | + |
| 40 | + - run: yarn lerna bootstrap |
| 41 | + - run: yarn build |
| 42 | + env: |
| 43 | + NODE_ENV: 'production' |
| 44 | + |
| 45 | + # Configure registry for GitHub Packages to install jarvis |
| 46 | + - run: rm ./.npmrc |
| 47 | + - run: | |
| 48 | + cat > .npmrc << EOF |
| 49 | + //npm.pkg.github.com/:_authToken=${GH_TOKEN} |
| 50 | + @typeform:registry=https://npm.pkg.github.com/ |
| 51 | + EOF |
| 52 | + env: |
| 53 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 54 | +
|
| 55 | + - run: yarn add -W @typeform/jarvis |
| 56 | + - run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private |
| 57 | + |
| 58 | + # Authenticate to AWS |
| 59 | + - uses: aws-actions/configure-aws-credentials@v4 |
| 60 | + with: |
| 61 | + aws-region: 'us-east-1' |
| 62 | + mask-aws-account-id: true |
| 63 | + role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }} |
| 64 | + role-session-name: ${{ github.run_id }}-${{ github.run_attempt }} |
| 65 | + role-duration-seconds: 900 |
| 66 | + unset-current-credentials: true |
| 67 | + |
| 68 | + - name: Deploy to AWS |
| 69 | + run: cd packages/embed && yarn release:aws |
| 70 | + env: |
| 71 | + AWS_ASSETS_BUCKET: 'typeform-public-assets/embed' |
| 72 | + AWS_CLOUDFRONT_DIST: 'E3IUO95IYL1RI3' |
| 73 | + PUBLIC_CDN_URL: 'https://embed.typeform.com' |
| 74 | + |
| 75 | + - uses: 8398a7/action-slack@v3 |
| 76 | + if: failure() |
| 77 | + with: |
| 78 | + status: ${{ job.status }} |
| 79 | + fields: repo,message,commit,author,action |
| 80 | + env: |
| 81 | + SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} |
0 commit comments