diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b1e72f2..ef7d8b5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -18,7 +18,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | @@ -45,6 +45,9 @@ jobs: deploy-preview: runs-on: ubuntu-latest name: deploy-preview + permissions: + contents: read + id-token: write steps: - name: Check out Git repository uses: actions/checkout@v3 @@ -55,7 +58,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: yarn-cache with: path: | @@ -82,12 +85,20 @@ jobs: - run: yarn add -W @typeform/jarvis - run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private (the file is committed by semantic-release to bump version) + # authenticate to AWS + - uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: 'us-east-1' + mask-aws-account-id: true + role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }} + role-session-name: ${{ github.run_id }}-${{ github.run_attempt }} + role-duration-seconds: 900 + unset-current-credentials: true + # deploy preview version of the package - run: yarn release:aws --preview --notify-preview env: AWS_ASSETS_BUCKET: 'typeform-public-assets/btn' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }} GH_TOKEN: ${{ secrets.GH_TOKEN }} JARVIS_NOTIFY_PREVIEW_TEMPLATE: ${{ secrets.JARVIS_NOTIFY_PREVIEW_TEMPLATE }} PUBLIC_CDN_URL: 'https://btn.typeform.com' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 895e39a..65094a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,10 @@ jobs: release: name: Release runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + packages: write steps: - name: Check out Git repository uses: actions/checkout@v3 @@ -18,7 +22,7 @@ jobs: node-version: 20 - name: Get yarn cache - uses: actions/cache@v3 + uses: actions/cache@v4 id: yarn-cache with: path: | @@ -47,12 +51,20 @@ jobs: - run: yarn add -W @typeform/jarvis - run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private (the file is committed by semantic-release to bump version) + # authenticate to AWS + - uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: 'us-east-1' + mask-aws-account-id: true + role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }} + role-session-name: ${{ github.run_id }}-${{ github.run_attempt }} + role-duration-seconds: 900 + unset-current-credentials: true + - run: yarn release env: AWS_ASSETS_BUCKET: 'typeform-public-assets/btn' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} AWS_CLOUDFRONT_DIST: 'E3IUO95IYL1RI3' - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }} GH_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} JARVIS_NOTIFY_PREVIEW_TEMPLATE: ${{ secrets.JARVIS_NOTIFY_PREVIEW_TEMPLATE }}