From 2c2d05ec2b9ecc389840b5e48859e6791f2ed9be Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Mon, 29 Aug 2022 11:41:04 -0500 Subject: [PATCH] add staging and prod deployment actions --- .github/workflows/release.yml | 44 ++++++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 45 +++++++++++++++++++++++++++++++++++ src/env.prod.ts | 9 +++++++ src/env.staging.ts | 9 +++++++ 4 files changed, 107 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/staging.yml create mode 100644 src/env.prod.ts create mode 100644 src/env.staging.ts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..93079fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release +on: + release: + types: [published] + paths-ignore: + - '**/README.md' + - '**/workflows/**' +jobs: + run: + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: npm ci + - name: Build + run: | + cp src/env.prod.ts src/env.ts; + npm run build + - name: Deploy + uses: reggionick/s3-deploy@v3.1.1 + with: + folder: dist + bucket: ${{ secrets.S3_BUCKET_CURATORFORM_PROD}} + bucket-region: ${{ secrets.S3_BUCKET_REGION }} + dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_PROD }} + invalidation: /* + delete-removed: true + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + with: + channel: "#deployment-updates" + color: 'good' + text: "A new version of the is deployed to production." + failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' + fields: | + [{ "title": "Commit message", "value": "${{ steps.extract_variables.outputs.MESSAGE }}" }, + { "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, + { "title": "Repository", "value": "", "short": true }, + { "title": "Branch", "value": "", "short": true }] \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..7face52 --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,45 @@ +name: Deploy Staging +on: + push: + branches: + - "staging" + paths-ignore: + - '**/README.md' + - '**/workflows/**' +jobs: + run: + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v2 + - name: Install + run: npm ci + - name: Build + run: | + cp src/env.staging.ts src/env.ts; + npm run build + - name: Deploy + uses: reggionick/s3-deploy@v3.1.1 + with: + folder: dist + bucket: ${{ secrets.S3_BUCKET_CURATORFORM_STAGING}} + bucket-region: ${{ secrets.S3_BUCKET_REGION }} + dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_CURATORFORM_STAGING }} + invalidation: /* + delete-removed: true + - name: Notify Slack + if: always() + uses: edge/simple-slack-notify@master + with: + channel: "#deployment-updates" + color: 'good' + text: "A new version of the is deployed to staging." + failure_text: '${env.GITHUB_WORKFLOW} (${env.GITHUB_RUN_NUMBER}) build failed' + fields: | + [{ "title": "Commit message", "value": "${{ steps.extract_variables.outputs.MESSAGE }}" }, + { "title": "Committed by", "value": "", "short": true }, + { "title": "Commit SHA", "value": "", "short": true }, + { "title": "Repository", "value": "", "short": true }, + { "title": "Branch", "value": "", "short": true }] diff --git a/src/env.prod.ts b/src/env.prod.ts new file mode 100644 index 0000000..731ca3c --- /dev/null +++ b/src/env.prod.ts @@ -0,0 +1,9 @@ +export const env = () => { + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.ror.org/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +} diff --git a/src/env.staging.ts b/src/env.staging.ts new file mode 100644 index 0000000..31663af --- /dev/null +++ b/src/env.staging.ts @@ -0,0 +1,9 @@ +export const env = () => { + const { + VUE_APP_BASE_ROUTE: BASE_ROUTE = '/', + VUE_APP_GENERATE_ID: GENERATE_ID = 'https://generateid.staging.ror.org/generateid', + VUE_APP_ADDRESS_URL: ADDRESS_URL = 'https://generateid.staging.ror.org/address', + NODE_ENV + } = process.env + return { BASE_ROUTE, GENERATE_ID, ADDRESS_URL, NODE_ENV } +}