From 2acb4df17caa598aba745483af9a3fe70826e8e4 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Thu, 21 Mar 2024 11:55:47 -0700 Subject: [PATCH] Add deployment preview workflow --- .github/workflows/pr-boxel-ui.yml | 85 +++++++++++++++++++++++++++++++ package.json | 2 + 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/pr-boxel-ui.yml diff --git a/.github/workflows/pr-boxel-ui.yml b/.github/workflows/pr-boxel-ui.yml new file mode 100644 index 0000000000..eccbe74a8c --- /dev/null +++ b/.github/workflows/pr-boxel-ui.yml @@ -0,0 +1,85 @@ +name: CI [boxel-ui] + +on: + pull_request: + paths: + - "packages/boxel-ui/**" + - ".github/workflows/pr-boxel-ui.yml" + - "package.json" + - "pnpm-lock.yaml" + +permissions: + contents: read + issues: read + checks: write + pull-requests: write + id-token: write + statuses: write + +jobs: + check-if-requires-preview: + name: Check if a preview deploy is required + runs-on: ubuntu-latest + outputs: + boxel-ui-files-changed: ${{ steps.boxel-ui-files-that-changed.outputs.any_changed }} + steps: + - uses: actions/checkout@v3 + - name: Get boxel-ui files that changed + id: boxel-ui-files-that-changed + uses: tj-actions/changed-files@v39 + with: + files: | + packages/boxel-ui/** + + deploy-ui-preview-staging: + name: Deploy a boxel-ui staging preview to S3 + runs-on: ubuntu-latest + # github.event.pull_request.head.repo.full_name == github.repository: true if pr is from the original repo, false if it's from a fork + # github.head_ref: the branch that the pull request is from. only appears on pull_request events + if: github.event.pull_request.head.repo.full_name == github.repository && github.head_ref && needs.check-if-requires-preview.outputs.boxel-ui-files-changed == 'true' + needs: check-if-requires-preview + concurrency: deploy-ui-preview-staging + steps: + - uses: actions/checkout@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: arn:aws:iam::680542703984:role/boxel-ui + aws-region: us-east-1 + - name: Deploy boxel-ui preview + uses: ./.github/actions/deploy-ember-preview + env: + S3_PREVIEW_BUCKET_NAME: boxel-ui-preview.stack.cards + AWS_S3_BUCKET: boxel-ui-preview.stack.cards + AWS_REGION: us-east-1 + AWS_CLOUDFRONT_DISTRIBUTION: E3Q2MVA30QSVUH + with: + package: boxel-ui + environment: staging + + deploy-ui-preview-production: + name: Deploy a boxel-ui production preview to S3 + runs-on: ubuntu-latest + # github.event.pull_request.head.repo.full_name == github.repository: true if pr is from the original repo, false if it's from a fork + # github.head_ref: the branch that the pull request is from. only appears on pull_request events + if: github.event.pull_request.head.repo.full_name == github.repository && github.head_ref && needs.check-if-requires-preview.outputs.boxel-ui-files-changed == 'true' + needs: check-if-requires-preview + concurrency: deploy-ui-preview-production + steps: + - uses: actions/checkout@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: arn:aws:iam::120317779495:role/boxel-host + aws-region: us-east-1 + - name: Deploy boxel-ui preview + uses: ./.github/actions/deploy-ember-preview + env: + S3_PREVIEW_BUCKET_NAME: boxel-ui-preview.cardstack.com + AWS_S3_BUCKET: boxel-ui-preview.cardstack.com + AWS_REGION: us-east-1 + # FIXME incorrect + AWS_CLOUDFRONT_DISTRIBUTION: E1JS2AYUPFW775 + with: + package: boxel-ui + environment: production diff --git a/package.json b/package.json index ce94cf77e2..50e65abd4f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "deploy:boxel-host:preview-staging": "cd packages/boxel-ui/addon && pnpm build && cd ../../host && BASE_REALM_HOSTING_DISABLED=true NODE_OPTIONS='--max_old_space_size=8192' pnpm exec ember deploy s3-preview-staging --verbose", "deploy:boxel-host:preview-production": "cd packages/boxel-ui/addon && pnpm build && cd ../../host && BASE_REALM_HOSTING_DISABLED=true NODE_OPTIONS='--max_old_space_size=8192' pnpm exec ember deploy s3-preview-production --verbose", "deploy:boxel-ui": "cd packages/boxel-ui/addon && pnpm build && cd ../test-app && pnpm exec ember deploy", + "deploy:boxel-ui:preview-staging": "cd packages/boxel-ui/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-staging --verbose", + "deploy:boxel-ui:preview-production": "cd packages/boxel-ui/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-production --verbose", "lint": "pnpm run --filter './packages/**' --if-present -r lint", "lint:fix": "pnpm run --filter './packages/**' --if-present -r lint:fix" },