Skip to content

Commit

Permalink
Merge pull request #501 from hodcroftlab/401-realign-deployment
Browse files Browse the repository at this point in the history
feat-401: realign deployment pipeline
  • Loading branch information
AdvancedCodingMonkey authored Feb 20, 2025
2 parents afc03ad + fb3810c commit ece0a9a
Show file tree
Hide file tree
Showing 25 changed files with 110 additions and 353 deletions.
26 changes: 2 additions & 24 deletions .github/workflows/build_app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ inputs:
runs:
using: "composite"
steps:
- name: "[build] Setup environment (${{ inputs.deploy_environment }})"
run: |
echo "[build] Setup environment (${{ inputs.deploy_environment }})"
echo "ENV_NAME=${{ inputs.deploy_environment }}" >> $GITHUB_ENV
echo "FULL_DOMAIN=https://covariants.org" >> $GITHUB_ENV
SUBDOMAIN=$( case ${{ inputs.deploy_environment }} in "staging" | "master") echo "${{ inputs.deploy_environment }}.";; *) echo "";; esac )
echo "PLAUSIBLE_IO_DOMAIN=${SUBDOMAIN}covariants.org" >> $GITHUB_ENV
shell: bash

- name: "[build] Setup Node.js"
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache-dependency-path: "web/yarn.lock"

- name: "[build] Setup cache for web app"
uses: actions/cache@v4
with:
Expand All @@ -39,14 +23,8 @@ runs:
echo "[build] Prepare .env file"
cd web/
cp .env.example .env
sed -i -e "s|FULL_DOMAIN=autodetect|FULL_DOMAIN=${FULL_DOMAIN}|g" .env
shell: bash

- name: "[build] Install Node.js packages"
run: |
echo "[build] Install Node.js packages"
cd web
yarn install --frozen-lockfile
sed -i -e "s|FULL_DOMAIN=autodetect|FULL_DOMAIN=https://covariants.org|g" .env
sed -i -e "s|DEPLOY_ENVIRONMENT=|DEPLOY_ENVIRONMENT=${{inputs.deploy_environment}}|g" .env
shell: bash

- name: "[build] Build web application"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/deploy_app_to_aws/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ name: "deploy app to aws"
runs:
using: "composite"
steps:
- name: "[deployment] Clear AWS S3 bucket: html files, web root, app bundle, keep checksums"
- name: "[deploy] Clear AWS S3 bucket: html files, web root, app bundle, keep checksums"
run: |
echo "[deployment] Clear AWS S3 bucket: html files, web root, app bundle, keep checksums"
aws s3 rm s3://${AWS_S3_BUCKET} --recursive --exclude "proteins/*" --exclude "acknowledgements/*" --exclude "checksums-ack-s3.txt"
shell: bash

- name: "[deployment] Copy to AWS S3: app bundle"
- name: "[deploy] Copy to AWS S3: app bundle"
run: |
echo "[deployment] Copy to AWS S3: app bundle"
cd web/.build/production/web
aws s3 cp --recursive --cache-control "max-age=2592000, public" "_next/" "s3://${AWS_S3_BUCKET}/_next/"
shell: bash

- name: "[deployment] Copy to AWS S3: web root"
- name: "[deploy] Copy to AWS S3: web root"
run: |
echo "[deployment] Copy to AWS S3: web root"
cd web/.build/production/web
Expand All @@ -28,7 +28,7 @@ runs:
"./" "s3://${AWS_S3_BUCKET}/"
shell: bash

- name: "[deployment] Copy to AWS S3: html files"
- name: "[deploy] Copy to AWS S3: html files"
run: |
echo "[deployment] Copy to AWS S3: html files"
cd web/.build/production/web
Expand All @@ -42,7 +42,7 @@ runs:
s3://${AWS_S3_BUCKET}/${file%.html}'
shell: bash

- name: "[deployment] Invalidate AWS Cloudfront cache: html files, web root, app bundle"
- name: "[deploy] Invalidate AWS Cloudfront cache: html files, web root, app bundle"
run: |
echo "[deployment] Invalidate AWS Cloudfront cache: html files, web root, app bundle"
aws cloudfront create-invalidation \
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/setup_node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "setup node"

runs:
using: "composite"
steps:
- name: "[init] Setup Node.js"
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache-dependency-path: "web/yarn.lock"

- name: "[init] Install Node.js packages"
run: |
echo "[build] Install Node.js packages"
cd web
yarn install --frozen-lockfile
shell: bash

- name: "[init] Install playwright dependencies"
run: |
echo "[init] Install playwright dependencies"
cd web
yarn playwright install --with-deps
shell: bash
20 changes: 10 additions & 10 deletions .github/workflows/sync_acknowledgements_checksum_based/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ name: "sync acknowledgements based on checksums"
runs:
using: "composite"
steps:
- name: "[deployment] Calculate acknowledgements checksums"
- name: "[deploy] Calculate acknowledgements checksums"
run: |
echo "[deployment] Calculate acknowledgements checksums"
echo "[deploy] Calculate acknowledgements checksums"
touch web/checksums-ack-ci.txt
cd web/.build/production/web/acknowledgements
find . -type f -printf "%P\n" | xargs -d '\n' sha256sum | awk '{print $2, $1}' | sort > ../../../../checksums-ack-ci.txt
shell: bash

- name: "[deployment] Compare acknowledgements checksums"
- name: "[deploy] Compare acknowledgements checksums"
run: |
echo "[deployment] Compare acknowledgements checksums"
echo "[deploy] Compare acknowledgements checksums"
cd web
if aws s3 ls s3://${AWS_S3_BUCKET}/checksums-ack-s3.txt; then
echo "s3 checksums found, downloading s3 checksums"
Expand All @@ -31,9 +31,9 @@ runs:
cat obsolete_acknowledgements.txt
shell: bash

- name: "[deployment] Sync acknowledgements files"
- name: "[deploy] Sync acknowledgements files"
run: |
echo "[deployment] Sync acknowledgements files"
echo "[deploy] Sync acknowledgements files"
echo "Removing obsolete files"
cd web
for file in $(cat obsolete_acknowledgements.txt); do
Expand All @@ -50,16 +50,16 @@ runs:
done
shell: bash

- name: "[deployment] Replace acknowledgements checksums in bucket"
- name: "[deploy] Replace acknowledgements checksums in bucket"
run: |
echo "[deployment] Replace acknowledgements checksums in bucket"
echo "[deploy] Replace acknowledgements checksums in bucket"
cd web
aws s3 cp checksums-ack-ci.txt s3://${AWS_S3_BUCKET}/checksums-ack-s3.txt
shell: bash

- name: "[deployment] Invalidate AWS Cloudfront cache: acknowledgements"
- name: "[deploy] Invalidate AWS Cloudfront cache: acknowledgements"
run: |
echo "[deployment] Invalidate AWS Cloudfront cache: acknowledgements"
echo "[deploy] Invalidate AWS Cloudfront cache: acknowledgements"
aws cloudfront create-invalidation \
--distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID} \
--paths "/acknowledgements/*"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/sync_proteins/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ name: "sync proteins"
runs:
using: "composite"
steps:
- name: "[deployment] Clear AWS S3 bucket: proteins"
- name: "[deploy] Clear AWS S3 bucket: proteins"
run: |
echo "[deployment] Clear AWS S3 bucket: proteins"
echo "[deploy] Clear AWS S3 bucket: proteins"
aws s3 rm s3://${AWS_S3_BUCKET} --recursive --exclude "*" --include "proteins/"
shell: bash

- name: "[deployment] Copy to AWS S3: proteins"
- name: "[deploy] Copy to AWS S3: proteins"
run: |
echo "[deployment] Copy to AWS S3: proteins"
echo "[deploy] Copy to AWS S3: proteins"
cd web/.build/production/web
aws s3 cp --recursive --cache-control "max-age=7200, public" --metadata-directive REPLACE "proteins/" "s3://${AWS_S3_BUCKET}/proteins/"
shell: bash

- name: "[deployment] Invalidate AWS Cloudfront cache: proteins"
- name: "[deploy] Invalidate AWS Cloudfront cache: proteins"
run: |
echo "[deployment] Invalidate AWS Cloudfront cache: proteins"
echo "[deploy] Invalidate AWS Cloudfront cache: proteins"
aws cloudfront create-invalidation \
--distribution-id ${AWS_CLOUDFRONT_DISTRIBUTION_ID} \
--paths "/proteins/*"
Expand Down
29 changes: 25 additions & 4 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,33 @@ jobs:
fetch-depth: 1
submodules: true

- name: "[init] Setup Node.js"
uses: ./.github/workflows/setup_node

- name: "[lint] Code formatting and CSS linting"
run: |
cd web
yarn format
yarn stylelint
- name: "[test] Run unit tests"
run: |
cd web
yarn test:unit
- name: "[build] Build app"
uses: ./.github/workflows/build_app
with:
deploy_environment: ${{ endsWith(github.ref, '/master') && 'master' || 'release' }}

- name: "[deployment] Install dependencies"
- name: "[test] Run end to end tests"
run: |
cd web
yarn test:e2e
env:
CI: true

- name: "[deploy] Install dependencies"
run: |
pushd /tmp >/dev/null
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Expand All @@ -64,7 +85,7 @@ jobs:
popd >/dev/null
aws --version
- name: "[deployment] Deploy app to aws"
- name: "[deploy] Deploy app to aws"
uses: ./.github/workflows/deploy_app_to_aws
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -73,7 +94,7 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}

- name: "[deployment] Sync acknowledgements (large static files)"
- name: "[deploy] Sync acknowledgements (large static files)"
uses: ./.github/workflows/sync_acknowledgements
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -82,7 +103,7 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}

- name: "[deployment] Sync proteins (large static files)"
- name: "[deploy] Sync proteins (large static files)"
uses: ./.github/workflows/sync_proteins
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
31 changes: 26 additions & 5 deletions .github/workflows/web_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,33 @@ jobs:
fetch-depth: 1
submodules: true

- name: "[build] Build app"
- name: "[init] Setup Node.js"
uses: ./.github/workflows/setup_node

- name: "[lint] Code formatting and CSS linting"
run: |
cd web
yarn format
yarn stylelint
- name: "[test] Run unit tests"
run: |
cd web
yarn test:unit
- name: "[build] Build app (also checks types and runs eslint)"
uses: ./.github/workflows/build_app
with:
deploy_environment: "staging"

- name: "[deployment] Install dependencies"
- name: "[test] Run end to end tests"
run: |
cd web
yarn test:e2e
env:
CI: true

- name: "[deploy] Install dependencies"
run: |
pushd /tmp >/dev/null
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Expand All @@ -61,7 +82,7 @@ jobs:
popd >/dev/null
aws --version
- name: "[deployment] Deploy app to aws"
- name: "[deploy] Deploy app to aws"
uses: ./.github/workflows/deploy_app_to_aws
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -70,7 +91,7 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}

- name: "[deployment] Sync acknowledgements (large static files) based on checksums"
- name: "[deploy] Sync acknowledgements (large static files) based on checksums"
uses: ./.github/workflows/sync_acknowledgements_checksum_based
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -79,7 +100,7 @@ jobs:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}

- name: "[deployment] Sync proteins (large static files)"
- name: "[deploy] Sync proteins (large static files)"
uses: ./.github/workflows/sync_proteins
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
17 changes: 0 additions & 17 deletions .vercelignore

This file was deleted.

17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,3 @@ otherwise. Thanks goes to these wonderful people ([emoji key](https://allcontrib

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
Contributions of any kind welcome!

---

<h3 id="sponsors" align="center">
🎁 Sponsors
</h3>

We are grateful to Vercel for sponsoring our web application builds

<p align="center">
<a target="_blank" href="https://vercel.com/?utm_source=hodcroftlab&utm_campaign=oss">
<img
src="https://user-images.githubusercontent.com/9403403/105740694-b9358880-5f39-11eb-95ff-3ea98e4fa43a.png"
alt="Vercel logo"
/>
</a>
</p>
7 changes: 0 additions & 7 deletions vercel.json

This file was deleted.

16 changes: 1 addition & 15 deletions web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,4 @@ PROFILE=0

WATCH_POLL=0

master_AWS_ACCESS_KEY_ID=
master_AWS_SECRET_ACCESS_KEY=
master_AWS_CLOUDFRONT_DISTRIBUTION_ID=
master_AWS_S3_BUCKET=covariants.org-master
master_ENV_NAME=master
master_FULL_DOMAIN=https://master.covariants.org
master_AWS_DEFAULT_REGION=us-east-1

release_AWS_ACCESS_KEY_ID=
release_AWS_SECRET_ACCESS_KEY=
release_AWS_CLOUDFRONT_DISTRIBUTION_ID=
release_AWS_S3_BUCKET=covariants.org
release_ENV_NAME=release
release_FULL_DOMAIN=https://covariants.org
release_AWS_DEFAULT_REGION=us-east-1
DEPLOY_ENVIRONMENT=
Loading

0 comments on commit ece0a9a

Please sign in to comment.