-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(liveness): add gh actions for releasing liveness (#3763)
* chore(liveness): add gh actions for releasing liveness * chore: update publish workflow for liveness-release * chore: add build trigger to latest publish * Update .github/workflows/liveness-branch-sync.yml Co-authored-by: William Lee <43682783+wlee221@users.noreply.github.com> * chore: add permissions for writing prs * chore: switch to specific commit for repo-sync, switch to aws-creds@v2 * chore: switch to using gh cli * chore: address comments --------- Co-authored-by: William Lee <43682783+wlee221@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |