Skip to content

Commit f5e4737

Browse files
committed
Add preliminary boxel-motion deployment setup
1 parent 4a7bec2 commit f5e4737

File tree

7 files changed

+232
-9
lines changed

7 files changed

+232
-9
lines changed

.github/workflows/deploy-motion.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy boxel-motion with ember
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
jobs:
15+
deploy:
16+
name: Deploy
17+
runs-on: ubuntu-latest
18+
concurrency: deploy-motion-${{ inputs.environment }}
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Init
23+
uses: ./.github/actions/init
24+
25+
- name: Set up env
26+
env:
27+
INPUT_ENVIRONMENT: ${{ inputs.environment }}
28+
run: |
29+
echo "AWS_REGION=us-east-1" >> $GITHUB_ENV
30+
if [ "$INPUT_ENVIRONMENT" = "production" ]; then
31+
echo "AWS_ROLE_ARN=arn:aws:iam::120317779495:role/boxel-motion" >> $GITHUB_ENV
32+
echo "AWS_S3_BUCKET=cardstack-boxel-motion-production" >> $GITHUB_ENV
33+
echo "AWS_CLOUDFRONT_DISTRIBUTION=ENCCIR73TMO8S" >> $GITHUB_ENV
34+
elif [ "$INPUT_ENVIRONMENT" = "staging" ]; then
35+
echo "AWS_ROLE_ARN=arn:aws:iam::680542703984:role/boxel-motion" >> $GITHUB_ENV
36+
echo "AWS_S3_BUCKET=cardstack-boxel-motion-staging" >> $GITHUB_ENV
37+
echo "AWS_CLOUDFRONT_DISTRIBUTION=E2ETE2PY0UMPR9" >> $GITHUB_ENV
38+
else
39+
echo "unrecognized environment"
40+
exit 1;
41+
fi
42+
# FIXME production cloudfront distribution
43+
- name: Build boxel-motion addon
44+
run: pnpm build
45+
working-directory: packages/boxel-motion/addon
46+
47+
- name: Configure AWS credentials
48+
uses: aws-actions/configure-aws-credentials@v3
49+
with:
50+
role-to-assume: ${{ env.AWS_ROLE_ARN }}
51+
aws-region: us-east-1
52+
53+
- name: Deploy
54+
run: pnpm deploy:boxel-motion ${{ inputs.environment }} --verbose
55+
56+
- name: Send notification to Discord
57+
uses: cardstack/gh-actions/discord-notification-deploy@main
58+
with:
59+
app: "boxel-motion"
60+
status: ${{ job.status }}
61+
environment: ${{ inputs.environment }}
62+
webhook: ${{ secrets.DISCORD_WEBHOOK }}

.github/workflows/manual-deploy.yml

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ jobs:
2929
with:
3030
environment: ${{ inputs.environment }}
3131

32+
deploy-motion:
33+
name: Deploy boxel-motion
34+
uses: ./.github/workflows/deploy-motion.yml
35+
secrets: inherit
36+
with:
37+
environment: ${{ inputs.environment }}
38+
3239
build-realm-server:
3340
name: Build Docker image
3441
uses: cardstack/gh-actions/.github/workflows/docker-ecr.yml@main

.github/workflows/pr-boxel-motion.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI [boxel-motion]
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "packages/boxel-motion/**"
7+
- ".github/workflows/pr-boxel-motion.yml"
8+
- "package.json"
9+
- "pnpm-lock.yaml"
10+
11+
permissions:
12+
contents: read
13+
issues: read
14+
checks: write
15+
pull-requests: write
16+
id-token: write
17+
statuses: write
18+
19+
jobs:
20+
check-if-requires-preview:
21+
name: Check if a preview deploy is required
22+
runs-on: ubuntu-latest
23+
outputs:
24+
boxel-motion-files-changed: ${{ steps.boxel-motion-files-that-changed.outputs.any_changed }}
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Get boxel-motion files that changed
28+
id: boxel-motion-files-that-changed
29+
uses: tj-actions/changed-files@v39
30+
with:
31+
files: |
32+
packages/boxel-motion/**
33+
deploy-motion-preview-staging:
34+
name: Deploy a boxel-motion staging preview to S3
35+
runs-on: ubuntu-latest
36+
# 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
37+
# github.head_ref: the branch that the pull request is from. only appears on pull_request events
38+
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'
39+
needs: check-if-requires-preview
40+
concurrency: deploy-motion-preview-staging
41+
steps:
42+
- uses: actions/checkout@v3
43+
- name: Configure AWS credentials
44+
uses: aws-actions/configure-aws-credentials@v3
45+
with:
46+
role-to-assume: arn:aws:iam::680542703984:role/boxel-motion
47+
aws-region: us-east-1
48+
- name: Deploy boxel-motion preview
49+
uses: ./.github/actions/deploy-ember-preview
50+
env:
51+
S3_PREVIEW_BUCKET_NAME: boxel-motion-preview.stack.cards
52+
AWS_S3_BUCKET: boxel-motion-preview.stack.cards
53+
AWS_REGION: us-east-1
54+
AWS_CLOUDFRONT_DISTRIBUTION: E1MA4A64V6KZJ6
55+
with:
56+
package: boxel-motion
57+
environment: staging
58+
59+
deploy-motion-preview-production:
60+
name: Deploy a boxel-motion production preview to S3
61+
runs-on: ubuntu-latest
62+
# 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
63+
# github.head_ref: the branch that the pull request is from. only appears on pull_request events
64+
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'
65+
needs: check-if-requires-preview
66+
concurrency: deploy-motion-preview-production
67+
steps:
68+
- uses: actions/checkout@v3
69+
- name: Configure AWS credentials
70+
uses: aws-actions/configure-aws-credentials@v3
71+
with:
72+
role-to-assume: arn:aws:iam::120317779495:role/boxel-motion
73+
aws-region: us-east-1
74+
- name: Deploy boxel-motion preview
75+
uses: ./.github/actions/deploy-ember-preview
76+
env:
77+
S3_PREVIEW_BUCKET_NAME: boxel-motion-preview.cardstack.com
78+
AWS_S3_BUCKET: boxel-motion-preview.cardstack.com
79+
AWS_REGION: us-east-1
80+
AWS_CLOUDFRONT_DISTRIBUTION: E1A4IR2R5TJZJZ
81+
# FIXME update
82+
with:
83+
package: boxel-motion
84+
environment: production

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
"url": "https://github.com/cardstack/boxel"
66
},
77
"scripts": {
8-
"build:boxel-host": "cd packages/boxel-ui/addon && pnpm build && cd ../../host && NODE_OPTIONS='--max_old_space_size=8192' pnpm build:production",
8+
"build:boxel-host": "cd packages/boxel-motion/addon && pnpm build && cd ../../host && NODE_OPTIONS='--max_old_space_size=8192' pnpm build:production",
99
"clear-caches": "find . -name 'node_modules' -type d -prune -exec rm -rf {} \\; && rm -rf $TMPDIR/embroider",
10-
"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",
11-
"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",
12-
"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",
10+
"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",
11+
"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",
12+
"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",
13+
"deploy:boxel-motion": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy",
14+
"deploy:boxel-motion:preview-staging": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-staging --verbose",
15+
"deploy:boxel-motion:preview-production": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-production --verbose",
1316
"lint": "pnpm run --filter './packages/**' --if-present -r lint",
1417
"lint:fix": "pnpm run --filter './packages/**' --if-present -r lint:fix"
1518
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* eslint-env node */
2+
3+
module.exports = function (deployTarget) {
4+
let ENV = {
5+
pipeline: {
6+
activateOnDeploy: true,
7+
},
8+
plugins: ['build', 'smart-compress', 'revision-data', 's3', 'cloudfront'],
9+
build: {},
10+
s3: {
11+
allowOverwrite: true,
12+
bucket: process.env.AWS_S3_BUCKET,
13+
region: process.env.AWS_REGION,
14+
filePattern: '**/*',
15+
},
16+
cloudfront: {
17+
objectPaths: ['/*'],
18+
distribution: process.env.AWS_CLOUDFRONT_DISTRIBUTION,
19+
},
20+
};
21+
22+
if (deployTarget === 'staging') {
23+
ENV.build.environment = 'production';
24+
}
25+
26+
if (deployTarget === 'production') {
27+
ENV.build.environment = 'production';
28+
}
29+
30+
if (deployTarget === 'build-only') {
31+
ENV.build.environment = 'production';
32+
ENV.plugins = ['build'];
33+
}
34+
35+
if (
36+
deployTarget === 's3-preview-staging' ||
37+
deployTarget === 's3-preview-production'
38+
) {
39+
ENV.s3.prefix = process.env.PR_BRANCH_NAME;
40+
}
41+
42+
return ENV;
43+
};

packages/boxel-motion/test-app/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
"ember-cli": "^4.12.1",
5656
"ember-cli-babel": "^8.2.0",
5757
"ember-cli-dependency-checker": "^3.3.1",
58+
"ember-cli-deploy": "^1.0.2",
59+
"ember-cli-deploy-build": "^2.0.0",
60+
"ember-cli-deploy-cloudfront": "^5.0.0",
61+
"ember-cli-deploy-revision-data": "^2.0.0",
62+
"ember-cli-deploy-s3": "^3.1.0",
63+
"ember-cli-deploy-smart-compress": "^2.0.0",
5864
"ember-cli-htmlbars": "^6.3.0",
5965
"ember-cli-inject-live-reload": "^2.1.0",
6066
"ember-cli-sri": "^2.1.1",

pnpm-lock.yaml

+23-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)