diff --git a/.github/workflows/liveness-branch-sync.yml b/.github/workflows/liveness-branch-sync.yml new file mode 100644 index 00000000000..d06c78f747e --- /dev/null +++ b/.github/workflows/liveness-branch-sync.yml @@ -0,0 +1,20 @@ +name: Liveness Release Branch Sync + +on: + push: + branches: [main] + +permissions: + pull-requests: write + +jobs: + branch-sync: + name: Branch Sync + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + - name: Create sync pull request + run: gh pr create -B liveness-release -H main --title 'Sync branch main to liveness-release' --body 'Created by Github action' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-liveness-latest.yml b/.github/workflows/publish-liveness-latest.yml new file mode 100644 index 00000000000..a590e144500 --- /dev/null +++ b/.github/workflows/publish-liveness-latest.yml @@ -0,0 +1,136 @@ +# Description: this workflow publishes liveness package to `latest` tag on NPM. +# +# Triggered by: whenever pr is merged to liveness-release + +# If successful, we will publish all updated UI packages to +# - https://www.npmjs.com/package/@aws-amplify/ui-react-liveness + +name: Test and Publish / liveness@latest + +on: + push: + branches: [liveness-release] + +permissions: + id-token: write # This is required for requesting the JWT + contents: write # Used to push tags to GitHub + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + + build-test: + runs-on: ubuntu-latest + needs: setup + environment: ci + steps: + - name: Checkout repo + uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + - name: Setup Node.js 16 + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + with: + node-version: 16 + cache: 'yarn' + env: + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 + - name: Add Amplify CLI + run: yarn global add @aws-amplify/cli + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: us-east-2 + role-to-assume: ${{ secrets.AUTH_E2E_ROLE_ARN }} + # Amplify CLI does not support headless pull with temporary credentials + # when useProfile is false. + # See: https://github.com/aws-amplify/amplify-cli/issues/11009. + - name: Create temp AWS profile + run: | + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \ + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \ + aws configure set aws_session_token $AWS_SESSION_TOKEN && \ + aws configure set default.region $AWS_REGION + - name: Pull down AWS environments + run: yarn pull + working-directory: ./canary + - name: Delete AWS Profile + run: rm -rf ~/.aws + - name: Setup canary apps against @next + run: yarn setup:next + working-directory: ./canary + - name: Run yarn install on each sample app + run: yarn install + working-directory: ./canary + - name: Run yarn build on each sample app + run: yarn build + working-directory: ./canary + + publish: + runs-on: ubuntu-latest + environment: deployment + needs: build-test + steps: + - name: Checkout repo + uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f + with: + # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits + fetch-depth: 0 + - name: Setup Node.js 16 + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + with: + node-version: 16 + cache: 'yarn' + env: + SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 + - name: Install packages + uses: ./.github/actions/install-with-retries + with: + skip-cypress-binary: true # publishing doesn't need cypress + - name: Build packages + run: yarn build + - name: Set liveness package to be public + run: yarn setLivenessPublic + - name: Publish to ui-react-liveness@latest + run: npm publish + working-directory: ./packages/react-liveness + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Trigger build for sample app + run: curl -X POST -d {} $ENDPOINT -H "Content-Type:application/json" + env: + ENDPOINT: ${{ secrets.LIVENESS_PROD_SAMPLE_APP_BUILD_TRIGGER }} + + log-failure-metric: + # Send a failure data point to metric PublishLatestFailure in github-workflows@ us-east-2 + runs-on: ubuntu-latest + environment: ci + needs: publish + if: ${{ failure() }} + steps: + - name: Log failure data point to metric PublishLatestFailure + uses: aws-amplify/amplify-ui/.github/actions/log-metric@main + with: + metric-name: PublishLivenessFailure + value: 1 + role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }} + aws-region: us-east-2 + + log-success-metric: + # Send a success data point to metric PublishLatestFailure in github-workflows@ us-east-2 + runs-on: ubuntu-latest + environment: ci + needs: publish + if: ${{ success() }} + steps: + - name: Log success data point to metric PublishLatestFailure + uses: aws-amplify/amplify-ui/.github/actions/log-metric@main + with: + metric-name: PublishLivenessFailure + value: 0 + role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }} + aws-region: us-east-2