From ae355eb7d1269b37e527be2be2d4ad9b617cabc1 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Tue, 26 Mar 2024 21:09:46 -0700 Subject: [PATCH] motion: Add deployments (#1110) This mirrors #1109 for boxel-motion. --- .github/workflows/deploy-motion.yml | 57 ++++++++++++++++++ .github/workflows/manual-deploy.yml | 7 +++ .github/workflows/pr-boxel-motion.yml | 58 +++++++++++++++++++ README.md | 8 +-- package.json | 2 + .../boxel-motion/test-app/config/deploy.js | 31 ++++++++++ packages/boxel-motion/test-app/package.json | 6 ++ pnpm-lock.yaml | 18 ++++++ 8 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy-motion.yml create mode 100644 .github/workflows/pr-boxel-motion.yml create mode 100644 packages/boxel-motion/test-app/config/deploy.js diff --git a/.github/workflows/deploy-motion.yml b/.github/workflows/deploy-motion.yml new file mode 100644 index 0000000000..5c869601e2 --- /dev/null +++ b/.github/workflows/deploy-motion.yml @@ -0,0 +1,57 @@ +name: Deploy boxel-motion with ember + +on: + workflow_call: + inputs: + environment: + required: true + type: string + +permissions: + contents: read + id-token: write + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + concurrency: deploy-motion-${{ inputs.environment }} + steps: + - uses: actions/checkout@v3 + + - name: Init + uses: ./.github/actions/init + + - name: Set up env + env: + INPUT_ENVIRONMENT: ${{ inputs.environment }} + run: | + echo "AWS_REGION=us-east-1" >> $GITHUB_ENV + if [ "$INPUT_ENVIRONMENT" = "staging" ]; then + echo "AWS_ROLE_ARN=arn:aws:iam::680542703984:role/boxel-motion" >> $GITHUB_ENV + echo "AWS_S3_BUCKET=cardstack-boxel-motion-staging" >> $GITHUB_ENV + echo "AWS_CLOUDFRONT_DISTRIBUTION=EC1OAKT1JEUGN" >> $GITHUB_ENV + else + echo "unrecognized environment" + exit 1; + fi + - name: Build boxel-motion addon + run: pnpm build + working-directory: packages/boxel-motion/addon + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 + with: + role-to-assume: ${{ env.AWS_ROLE_ARN }} + aws-region: us-east-1 + + - name: Deploy + run: pnpm deploy:boxel-motion ${{ inputs.environment }} --verbose + + - name: Send notification to Discord + uses: cardstack/gh-actions/discord-notification-deploy@main + with: + app: "boxel-motion" + status: ${{ job.status }} + environment: ${{ inputs.environment }} + webhook: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml index 7d052755dd..b0d19760f5 100644 --- a/.github/workflows/manual-deploy.yml +++ b/.github/workflows/manual-deploy.yml @@ -29,6 +29,13 @@ jobs: with: environment: ${{ inputs.environment }} + deploy-motion: + name: Deploy boxel-motion + uses: ./.github/workflows/deploy-motion.yml + secrets: inherit + with: + environment: staging + deploy-ui: name: Deploy boxel-ui uses: ./.github/workflows/deploy-ui.yml diff --git a/.github/workflows/pr-boxel-motion.yml b/.github/workflows/pr-boxel-motion.yml new file mode 100644 index 0000000000..dcb41faded --- /dev/null +++ b/.github/workflows/pr-boxel-motion.yml @@ -0,0 +1,58 @@ +name: CI [boxel-motion] + +on: + pull_request: + paths: + - "packages/boxel-motion/**" + - ".github/workflows/pr-boxel-motion.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-motion-files-changed: ${{ steps.boxel-motion-files-that-changed.outputs.any_changed }} + steps: + - uses: actions/checkout@v3 + - name: Get boxel-motion files that changed + id: boxel-motion-files-that-changed + uses: tj-actions/changed-files@v39 + with: + files: | + packages/boxel-motion/** + + deploy-motion-preview-staging: + name: Deploy a boxel-motion 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-motion-files-changed == 'true' + needs: check-if-requires-preview + concurrency: deploy-motion-preview-staging-${{ github.head_ref || github.run_id }} + 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-motion + aws-region: us-east-1 + - name: Deploy boxel-motion preview + uses: ./.github/actions/deploy-ember-preview + env: + S3_PREVIEW_BUCKET_NAME: boxel-motion-preview.stack.cards + AWS_S3_BUCKET: boxel-motion-preview.stack.cards + AWS_REGION: us-east-1 + AWS_CLOUDFRONT_DISTRIBUTION: E25VU6BCHNF7AR + with: + package: boxel-motion + environment: staging diff --git a/README.md b/README.md index c8c3d0ddbf..beee4d4ebd 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,11 @@ For a quickstart, see [here](./QUICKSTART.md) `packages/boxel-ui/addon` is the UI components Ember addon -`packages/boxel-ui/test-app` is the test suite and component explorer for boxel-ui +`packages/boxel-ui/test-app` is the test suite and component explorer for boxel-ui, deployed at [boxel-ui.stack.cards](https://boxel-ui.stack.cards) -`packages/boxel-motion` is the animation primitives ember addon. +`packages/boxel-motion/addon` is the animation primitives ember addon. -`packages/boxel-motion-test-app` is the test suite for boxel-motion - -`packages/boxel-motion/test-app` is the demo app for boxel-motion +`packages/boxel-motion/test-app` is the demo app for boxel-motion, deployed at [boxel-motion.stack.cards](https://boxel-motion.stack.cards) `packages/matrix` is the docker container for running the matrix server: synapse, as well as tests that involve running a matrix client. diff --git a/package.json b/package.json index f6fcff2319..a5f09723af 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "deploy:boxel-host": "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", "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-motion": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy", + "deploy:boxel-motion:preview-staging": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-staging --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", "lint": "pnpm run --filter './packages/**' --if-present -r lint", diff --git a/packages/boxel-motion/test-app/config/deploy.js b/packages/boxel-motion/test-app/config/deploy.js new file mode 100644 index 0000000000..031b4c8d92 --- /dev/null +++ b/packages/boxel-motion/test-app/config/deploy.js @@ -0,0 +1,31 @@ +/* eslint-env node */ + +module.exports = function (deployTarget) { + let ENV = { + pipeline: { + activateOnDeploy: true, + }, + plugins: ['build', 'smart-compress', 'revision-data', 's3', 'cloudfront'], + build: {}, + s3: { + allowOverwrite: true, + bucket: process.env.AWS_S3_BUCKET, + region: process.env.AWS_REGION, + filePattern: '**/*', + }, + cloudfront: { + objectPaths: ['/*'], + distribution: process.env.AWS_CLOUDFRONT_DISTRIBUTION, + }, + }; + + if (deployTarget === 'staging') { + ENV.build.environment = 'production'; + } + + if (deployTarget === 's3-preview-staging') { + ENV.s3.prefix = process.env.PR_BRANCH_NAME; + } + + return ENV; +}; diff --git a/packages/boxel-motion/test-app/package.json b/packages/boxel-motion/test-app/package.json index 0da17aeb60..2295ba51dd 100644 --- a/packages/boxel-motion/test-app/package.json +++ b/packages/boxel-motion/test-app/package.json @@ -55,6 +55,12 @@ "ember-cli": "^4.12.1", "ember-cli-babel": "^8.2.0", "ember-cli-dependency-checker": "^3.3.1", + "ember-cli-deploy": "^1.0.2", + "ember-cli-deploy-build": "^2.0.0", + "ember-cli-deploy-cloudfront": "^5.0.0", + "ember-cli-deploy-revision-data": "^2.0.0", + "ember-cli-deploy-s3": "^3.1.0", + "ember-cli-deploy-smart-compress": "^2.0.0", "ember-cli-deprecation-workflow": "mixonic/ember-cli-deprecation-workflow#0b4cbe7", "ember-cli-htmlbars": "^6.3.0", "ember-cli-inject-live-reload": "^2.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2cc036ae78..bb811cd300 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -451,6 +451,24 @@ importers: ember-cli-dependency-checker: specifier: ^3.3.1 version: 3.3.1(ember-cli@4.12.1) + ember-cli-deploy: + specifier: ^1.0.2 + version: 1.0.2 + ember-cli-deploy-build: + specifier: ^2.0.0 + version: 2.0.0 + ember-cli-deploy-cloudfront: + specifier: ^5.0.0 + version: 5.0.0 + ember-cli-deploy-revision-data: + specifier: ^2.0.0 + version: 2.0.0 + ember-cli-deploy-s3: + specifier: ^3.1.0 + version: 3.1.0 + ember-cli-deploy-smart-compress: + specifier: ^2.0.0 + version: 2.0.0 ember-cli-deprecation-workflow: specifier: mixonic/ember-cli-deprecation-workflow#0b4cbe7 version: github.com/mixonic/ember-cli-deprecation-workflow/0b4cbe7(ember-source@4.12.0)