Skip to content

fix: deployment workflows (#56) #46

fix: deployment workflows (#56)

fix: deployment workflows (#56) #46

Workflow file for this run

name: Demo deployment workflow
on:
push:
branches:
- develop
jobs:
format-and-test:
runs-on: ubuntu-latest
permissions:
contents: 'read'
actions: 'read'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'develop'
workflow-id: 'deploy-demo.yml'
- run: npm ci
- run: npx nx format:check --exclude=acq,core,discord,discord-bot-ui,discord-bot-ui-e2e,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts
- run: npx nx run-many --target=test --parallel=3 --exclude=acq,core,discord,discord-bot-ui,discord-bot-ui-e2e,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --skip-nx-cache
- run: npx nx run-many --target=build --parallel=3 --exclude=acq,core,discord,discord-bot-ui,discord-bot-ui-e2e,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --skip-nx-cache
deploy:
runs-on: ubuntu-latest
needs: format-and-test
permissions:
contents: 'read'
actions: 'read'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'develop'
workflow-id: 'deploy-demo.yml'
- run: npm ci
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: 'eu-central-1'
- run: npx nx run-many --target=build --parallel=3 --exclude=acq,core,discord,discord-bot-ui,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --skip-nx-cache
- run: npx nx run-many --target=build-server --parallel=3 --exclude=acq,core,discord,discord-bot-ui,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --skip-nx-cache
- run: npx nx run-many --target=export --exclude=acq,core,discord,discord-bot-ui,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --skip-nx-cache
- name: Setup staging env file
if: github.ref == 'refs/heads/develop'
env:
CERTIFICATE_ARN: ${{ secrets.STAGING_SIWT_XYZ_SSL_CERTIFICATE_ARN }}
ENV: staging
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_SIWT_XYZ_DISTRIBUTION_ID }}
run: |
touch .env
echo SSL_CERTIFICATE_ARN=$CERTIFICATE_ARN >> .env
echo ENV=$ENV >> .env
cat .env
- name: Setup production env file
if: github.ref == 'refs/heads/main'
env:
CERTIFICATE_ARN: ${{ secrets.SIWT_XYZ_SSL_CERTIFICATE_ARN }}
ENV: production
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.SIWT_XYZ_DISTRIBUTION_ID }}
run: |
touch .env
echo SSL_CERTIFICATE_ARN=$CERTIFICATE_ARN >> .env
echo ENV=$ENV >> .env
cat .env
- name: Deploy
run: npx nx run-many --target=deploy --exclude=acq,core,discord,discord-bot-ui,discord-bot-ui-e2e,react,sdk,docs.siwt.xyz,siwt.xyz-e2e,smart-contracts --production --skip-nx-cache
- name: Invalidate Staging Distribution
if: github.ref == 'refs/heads/develop'
env:
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_SIWT_XYZ_DISTRIBUTION_ID }}
run: aws cloudfront create-invalidation --distribution-id=$CLOUDFRONT_DISTRIBUTION_ID --paths '/*'
- name: Invalidate Production Distribution
if: github.ref == 'refs/heads/main'
env:
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.SIWT_XYZ_DISTRIBUTION_ID }}
run: aws cloudfront create-invalidation --distribution-id=$CLOUDFRONT_DISTRIBUTION_ID --paths '/*'