Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Add deployments #1109

Merged
merged 27 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b664176
Add preliminary UI deployment
backspace Mar 21, 2024
73e0e4a
Add run on push
backspace Mar 21, 2024
1804e99
Add temporary fixed input
backspace Mar 21, 2024
d3ff456
Add explicit build
backspace Mar 21, 2024
8bf8558
Add another hardcoded environment
backspace Mar 21, 2024
d094419
Remove notification
backspace Mar 21, 2024
b1d38e4
Remove build reuse
backspace Mar 21, 2024
efcf478
Add deployment on main pushes
backspace Mar 21, 2024
2acb4df
Add deployment preview workflow
backspace Mar 21, 2024
567fef4
Fix indentation
backspace Mar 21, 2024
35c1a19
Fix production Cloudfront distributions
backspace Mar 21, 2024
e1d263f
Change deployment workflow to be for main
backspace Mar 21, 2024
50cf0f5
Add random change to boxel-ui
backspace Mar 21, 2024
3cbf1ae
Add empty commit
backspace Mar 21, 2024
e06a3a4
Fix production preview role
backspace Mar 21, 2024
3959e54
Add package name to check description
backspace Mar 21, 2024
478153a
Remove usage hack
backspace Mar 21, 2024
f8d43a8
Merge branch 'main' into ui/deploy-cs-6634
backspace Mar 21, 2024
ea0a960
Remove staging deployments
backspace Mar 22, 2024
2fefa66
Remove more staging setup
backspace Mar 22, 2024
ded04d3
Remove unused deployment target
backspace Mar 22, 2024
951b202
Merge branch 'main' into ui/deploy-cs-6634
backspace Mar 26, 2024
de758b2
Change ui deployments to staging
backspace Mar 26, 2024
2593a35
Fix deployment script name
backspace Mar 26, 2024
cb59b35
Add another temporary test-app change
backspace Mar 26, 2024
dc19818
Remove display change
backspace Mar 26, 2024
5edc4bb
Add concurrency suffixes
backspace Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/deploy-ember-preview/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ runs:
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPOSITORY/statuses/$HEAD_SHA \
-d '{"context":"Preview ${{ inputs.package }} ${{ inputs.environment }}","description":"${{ inputs.environment }} deployment of this branch","target_url":"'"$PREVIEW_HOST"'","state":"success"}'
-d '{"context":"Preview ${{ inputs.package }} ${{ inputs.environment }}","description":"${{ inputs.environment }} ${{ inputs.package }} deployment of this branch","target_url":"'"$PREVIEW_HOST"'","state":"success"}'
57 changes: 57 additions & 0 deletions .github/workflows/deploy-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Deploy boxel-ui 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-ui-${{ 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-ui" >> $GITHUB_ENV
echo "AWS_S3_BUCKET=cardstack-boxel-ui-production" >> $GITHUB_ENV
echo "AWS_CLOUDFRONT_DISTRIBUTION=ENCCIR73TMO8S" >> $GITHUB_ENV
else
echo "unrecognized environment"
exit 1;
fi
- name: Build boxel-ui addon
run: pnpm build
working-directory: packages/boxel-ui/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-ui ${{ inputs.environment }} --verbose

- name: Send notification to Discord
uses: cardstack/gh-actions/discord-notification-deploy@main
with:
app: "boxel-ui"
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-ui:
name: Deploy boxel-ui
uses: ./.github/workflows/deploy-ui.yml
secrets: inherit
with:
environment: production

build-realm-server:
name: Build Docker image
uses: cardstack/gh-actions/.github/workflows/docker-ecr.yml@main
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/pr-boxel-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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-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-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.cardstack.com
AWS_S3_BUCKET: boxel-ui-preview.cardstack.com
AWS_REGION: us-east-1
AWS_CLOUDFRONT_DISTRIBUTION: E1A4IR2R5TJZJZ
with:
package: boxel-ui
environment: production
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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-ui": "cd packages/boxel-ui/addon && pnpm build && cd ../test-app && pnpm exec ember deploy",
"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"
},
Expand Down
31 changes: 31 additions & 0 deletions packages/boxel-ui/test-app/config/deploy.js
Original file line number Diff line number Diff line change
@@ -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 === 'production') {
ENV.build.environment = 'production';
}

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

return ENV;
};
6 changes: 6 additions & 0 deletions packages/boxel-ui/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
"ember-auto-import": "^2.6.3",
"ember-cli": "^4.12.1",
"ember-cli-babel": "^8.2.0",
"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-dependency-checker": "^3.3.1",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-inject-live-reload": "^2.1.0",
Expand Down
24 changes: 21 additions & 3 deletions pnpm-lock.yaml

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

Loading