feat: set environment #58
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Demo deployment workflow | |
on: | |
push: | |
branches: | |
- develop | |
- fix/deployment_workflows | |
jobs: | |
format-and-test: | |
runs-on: ubuntu-latest | |
environment: Production | |
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 test siwt.xyz --skip-nx-cache | |
- run: npx nx build siwt.xyz --skip-nx-cache | |
deploy: | |
runs-on: ubuntu-latest | |
needs: format-and-test | |
environment: Production | |
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' | |
- name: Setup production env file | |
if: github.ref == 'refs/heads/develop' | |
env: | |
ENV: production | |
CERTIFICATE_ARN: ${{ secrets.SIWT_XYZ_SSL_CERTIFICATE_ARN }} | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.SIWT_XYZ_DISTRIBUTION_ID }} | |
NEXT_PUBLIC_DAPP_URL: ${{ vars.SIWT_XYZ_DAPP_URL }} | |
NEXT_PUBLIC_NEXT_AUTH_CLIENT_ID: ${{ vars.NEXT_PUBLIC_NEXT_AUTH_CLIENT_ID }} | |
NEXT_AUTH_CLIENT_SECRET: ${{ secrets.NEXT_AUTH_CLIENT_SECRET }} | |
NEXT_AUTH_OIDC_PUBLIC_URL: ${{ vars.NEXT_AUTH_OIDC_PUBLIC_URL }} | |
NEXTAUTH_URL: ${{ vars.NEXTAUTH_URL }} | |
NEXTAUTH_SECRET: ${{ secrets.KuS08kEIMZ68PSo3 }} | |
run: | | |
touch .env | |
echo SSL_CERTIFICATE_ARN=$CERTIFICATE_ARN >> .env | |
echo ENV=$ENV >> .env | |
cat .env | |
- name: Deploy | |
run: npx nx deploy siwt.xyz --production --skip-nx-cache | |
- name: Invalidate Distribution | |
if: github.ref == 'refs/heads/develop' | |
env: | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.SIWT_XYZ_DISTRIBUTION_ID }} | |
run: aws cloudfront create-invalidation --distribution-id=$CLOUDFRONT_DISTRIBUTION_ID --paths '/*' |