Skip to content

Commit

Permalink
Add preliminary boxel-motion deployment setup
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Mar 21, 2024
1 parent 4a7bec2 commit f5e4737
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 9 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy-motion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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" = "production" ]; then
echo "AWS_ROLE_ARN=arn:aws:iam::120317779495:role/boxel-motion" >> $GITHUB_ENV
echo "AWS_S3_BUCKET=cardstack-boxel-motion-production" >> $GITHUB_ENV
echo "AWS_CLOUDFRONT_DISTRIBUTION=ENCCIR73TMO8S" >> $GITHUB_ENV
elif [ "$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=E2ETE2PY0UMPR9" >> $GITHUB_ENV
else
echo "unrecognized environment"
exit 1;
fi
# FIXME production cloudfront distribution
- 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 }}
7 changes: 7 additions & 0 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ${{ inputs.environment }}

build-realm-server:
name: Build Docker image
uses: cardstack/gh-actions/.github/workflows/docker-ecr.yml@main
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/pr-boxel-motion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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
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: E1MA4A64V6KZJ6
with:
package: boxel-motion
environment: staging

deploy-motion-preview-production:
name: Deploy a boxel-motion 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-motion-files-changed == 'true'
needs: check-if-requires-preview
concurrency: deploy-motion-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-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.cardstack.com
AWS_S3_BUCKET: boxel-motion-preview.cardstack.com
AWS_REGION: us-east-1
AWS_CLOUDFRONT_DISTRIBUTION: E1A4IR2R5TJZJZ
# FIXME update
with:
package: boxel-motion
environment: production
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
"url": "https://github.com/cardstack/boxel"
},
"scripts": {
"build:boxel-host": "cd packages/boxel-ui/addon && pnpm build && cd ../../host && NODE_OPTIONS='--max_old_space_size=8192' pnpm build:production",
"build:boxel-host": "cd packages/boxel-motion/addon && pnpm build && cd ../../host && NODE_OPTIONS='--max_old_space_size=8192' pnpm build:production",
"clear-caches": "find . -name 'node_modules' -type d -prune -exec rm -rf {} \\; && rm -rf $TMPDIR/embroider",
"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-host": "cd packages/boxel-motion/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-motion/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-motion/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-motion:preview-production": "cd packages/boxel-motion/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"
},
Expand Down
43 changes: 43 additions & 0 deletions packages/boxel-motion/test-app/app/config/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* 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 === 'production') {
ENV.build.environment = 'production';
}

if (deployTarget === 'build-only') {
ENV.build.environment = 'production';
ENV.plugins = ['build'];
}

if (
deployTarget === 's3-preview-staging' ||
deployTarget === 's3-preview-production'
) {
ENV.s3.prefix = process.env.PR_BRANCH_NAME;
}

return ENV;
};
6 changes: 6 additions & 0 deletions packages/boxel-motion/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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-htmlbars": "^6.3.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-sri": "^2.1.1",
Expand Down
28 changes: 23 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5e4737

Please sign in to comment.