From 55ed90a60e4db8ff573366c9af4f6628f40d005c Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 16 Jun 2020 12:43:53 -0700 Subject: [PATCH 1/5] Frontend CD workflow --- .../Continuous_Deployment_Frontend_Dev.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/Continuous_Deployment_Frontend_Dev.yml diff --git a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml new file mode 100644 index 000000000..c7c67abf6 --- /dev/null +++ b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml @@ -0,0 +1,45 @@ +name: DevDeployCI +on: + push: + branches: + - 656-FRONT-continuousDeployment +# env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # AWS_DEFAULT_REGION: 'us-east-1' + # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check-out Repository Code + uses: actions/checkout@v1 + - name: Rebuild sass + run: npm rebuild node-sass + - name: Install Packages + run: npm install + - name: Setup environment + run: | + echo REACT_APP_MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }} > .env + echo DB_URL=${{ secrets.DB_URL }} >> .env + echo MIXPANEL_ENABLED=${{ secrets.MIXPANEL_ENABLED }} >> .env + echo MIXPANEL_TOKEN_PROD=${{ secrets.MIXPANEL_TOKEN_PROD }} >> .env + echo MIXPANEL_TOKEN_DEV=${{ secrets.MIXPANEL_TOKEN_DEV }} >> .env + echo GITHUB_SHA=${{ github.sha }} >> .env + - name: Build project + run: npm run build + - name: Run Tests + run: export CI=true && npm run test -- --coverage + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Upload Development Build To S3 + run: | + aws s3 sync dist s3://${{ secrets.S3_BUCKET_DEV }} --follow-symlinks --delete + - name: Invalidate Cloudfront Cache + run: | + aws cloudfront create-invalidation --distribution-id ${{ secrets.CDN_DISTRIBUTION_ID_DEV }} --paths "/*" \ No newline at end of file From 4dadaf0ebddcf24e139ebf7f0c46f0217dd0954d Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 16 Jun 2020 12:54:49 -0700 Subject: [PATCH 2/5] Updated aws secrets --- .github/workflows/Continuous_Deployment_Frontend_Dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml index c7c67abf6..40c5a7456 100644 --- a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml +++ b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml @@ -34,8 +34,8 @@ jobs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-access-key-id: ${{ secrets.AWS_CI_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_CI_SECRET_ACCESS_KEY }} aws-region: us-east-1 - name: Upload Development Build To S3 run: | From 472089762de75a67d8ba5a725e9b4fe7dc766350 Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 16 Jun 2020 14:39:15 -0700 Subject: [PATCH 3/5] Updated dev DB_URL --- .../Continuous_Deployment_Frontend_Dev.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml index 40c5a7456..3f9b91947 100644 --- a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml +++ b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml @@ -2,18 +2,13 @@ name: DevDeployCI on: push: branches: - - 656-FRONT-continuousDeployment -# env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # AWS_DEFAULT_REGION: 'us-east-1' - # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - dev jobs: build: runs-on: ubuntu-latest steps: - - name: Check-out Repository Code + - name: Checkout Repository Code uses: actions/checkout@v1 - name: Rebuild sass run: npm rebuild node-sass @@ -22,7 +17,7 @@ jobs: - name: Setup environment run: | echo REACT_APP_MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }} > .env - echo DB_URL=${{ secrets.DB_URL }} >> .env + echo DB_URL=${{ secrets.SERVER_URL_DEV }} >> .env echo MIXPANEL_ENABLED=${{ secrets.MIXPANEL_ENABLED }} >> .env echo MIXPANEL_TOKEN_PROD=${{ secrets.MIXPANEL_TOKEN_PROD }} >> .env echo MIXPANEL_TOKEN_DEV=${{ secrets.MIXPANEL_TOKEN_DEV }} >> .env @@ -37,7 +32,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_CI_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_CI_SECRET_ACCESS_KEY }} aws-region: us-east-1 - - name: Upload Development Build To S3 + - name: Sync Development Build To S3 run: | aws s3 sync dist s3://${{ secrets.S3_BUCKET_DEV }} --follow-symlinks --delete - name: Invalidate Cloudfront Cache From bb8fb6398dbb6acc40839675511da27fb95ebe4f Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 16 Jun 2020 14:40:18 -0700 Subject: [PATCH 4/5] Frontend production CD workflow --- .github/workflows/Continuous_Delivery.yml | 66 ------------------- .../Continuous_Deployment_Frontend_Prod.yml | 61 +++++++++++++++++ 2 files changed, 61 insertions(+), 66 deletions(-) delete mode 100644 .github/workflows/Continuous_Delivery.yml create mode 100644 .github/workflows/Continuous_Deployment_Frontend_Prod.yml diff --git a/.github/workflows/Continuous_Delivery.yml b/.github/workflows/Continuous_Delivery.yml deleted file mode 100644 index b3efed7ff..000000000 --- a/.github/workflows/Continuous_Delivery.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: MasterDeployCI -on: - push: - branches: - - master -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - tf_version: 'latest' - tf_working_dir: './Orchestration/terraform' - AWS_DEFAULT_REGION: 'us-east-1' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Rebuild sass - run: npm rebuild node-sass - - name: Install Packages - run: npm install - - name: Setup environment - run: | - echo REACT_APP_MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }} > .env - echo DB_URL=${{ secrets.DB_URL }} >> .env - echo MIXPANEL_ENABLED=${{ secrets.MIXPANEL_ENABLED }} >> .env - echo MIXPANEL_TOKEN_PROD=${{ secrets.MIXPANEL_TOKEN_PROD }} >> .env - echo MIXPANEL_TOKEN_DEV=${{ secrets.MIXPANEL_TOKEN_DEV }} >> .env - echo GITHUB_SHA=${{ github.sha }} >> .env - - name: Build project - run: npm run build - - name: Run Tests - run: export CI=true && npm run test -- --coverage - - name: Deploy to GH pages - uses: JamesIves/github-pages-deploy-action@master - env: - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - REACT_APP_MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }} - DB_URL: ${{ secrets.DB_URL }} - MIXPANEL_ENABLED: ${{ secrets.MIXPANEL_ENABLED }} - MIXPANEL_TOKEN_PROD: ${{ secrets.MIXPANEL_TOKEN_PROD }} - MIXPANEL_TOKEN_DEV: ${{ secrets.MIXPANEL_TOKEN_DEV }} - BASE_BRANCH: master # The branch the action should deploy from. - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: dist # The folder the action should deploy. - # - name: Terraform Init - # uses: hashicorp/terraform-github-actions@master - # with: - # tf_actions_version: ${{ env.tf_version }} - # tf_actions_working_dir: ${{ env.tf_working_dir }} - # tf_actions_subcommand: 'init' - # - name: Terraform Validate - # uses: hashicorp/terraform-github-actions@master - # with: - # tf_actions_version: ${{ env.tf_version }} - # tf_actions_working_dir: ${{ env.tf_working_dir }} - # tf_actions_subcommand: 'validate' - # tf_actions_comment: true - # - name: Terraform Apply - # uses: hashicorp/terraform-github-actions@master - # with: - # tf_actions_version: ${{ env.tf_version }} - # tf_actions_working_dir: ${{ env.tf_working_dir }} - # tf_actions_subcommand: 'apply' - # tf_actions_comment: true diff --git a/.github/workflows/Continuous_Deployment_Frontend_Prod.yml b/.github/workflows/Continuous_Deployment_Frontend_Prod.yml new file mode 100644 index 000000000..2aae4b72b --- /dev/null +++ b/.github/workflows/Continuous_Deployment_Frontend_Prod.yml @@ -0,0 +1,61 @@ +name: MasterDeployCI +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository Code + uses: actions/checkout@v1 + - name: Rebuild sass + run: npm rebuild node-sass + - name: Install Packages + run: npm install + - name: Setup environment + run: | + echo REACT_APP_MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }} > .env + echo DB_URL=${{ secrets.DB_URL }} >> .env + echo MIXPANEL_ENABLED=${{ secrets.MIXPANEL_ENABLED }} >> .env + echo MIXPANEL_TOKEN_PROD=${{ secrets.MIXPANEL_TOKEN_PROD }} >> .env + echo MIXPANEL_TOKEN_DEV=${{ secrets.MIXPANEL_TOKEN_DEV }} >> .env + echo GITHUB_SHA=${{ github.sha }} >> .env + - name: Build project + run: npm run build + - name: Run Tests + run: export CI=true && npm run test -- --coverage + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_CI_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_CI_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Sync Production Build To S3 + run: | + aws s3 sync dist s3://${{ secrets.S3_BUCKET_PROD }} --follow-symlinks --delete + - name: Invalidate Cloudfront Cache + run: | + aws cloudfront create-invalidation --distribution-id ${{ secrets.CDN_DISTRIBUTION_ID_PROD }} --paths "/*" + + # - name: Terraform Init + # uses: hashicorp/terraform-github-actions@master + # with: + # tf_actions_version: ${{ env.tf_version }} + # tf_actions_working_dir: ${{ env.tf_working_dir }} + # tf_actions_subcommand: 'init' + # - name: Terraform Validate + # uses: hashicorp/terraform-github-actions@master + # with: + # tf_actions_version: ${{ env.tf_version }} + # tf_actions_working_dir: ${{ env.tf_working_dir }} + # tf_actions_subcommand: 'validate' + # tf_actions_comment: true + # - name: Terraform Apply + # uses: hashicorp/terraform-github-actions@master + # with: + # tf_actions_version: ${{ env.tf_version }} + # tf_actions_working_dir: ${{ env.tf_working_dir }} + # tf_actions_subcommand: 'apply' + # tf_actions_comment: true From 58ead03c7458e589c0a0f55c545e7bab4c6425e4 Mon Sep 17 00:00:00 2001 From: Adam Kendis Date: Tue, 16 Jun 2020 16:54:44 -0700 Subject: [PATCH 5/5] Removed testing from deployment workflows --- .github/workflows/Continuous_Deployment_Frontend_Dev.yml | 4 +--- .github/workflows/Continuous_Deployment_Frontend_Prod.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml index 3f9b91947..890122014 100644 --- a/.github/workflows/Continuous_Deployment_Frontend_Dev.yml +++ b/.github/workflows/Continuous_Deployment_Frontend_Dev.yml @@ -1,4 +1,4 @@ -name: DevDeployCI +name: DevDeploy on: push: branches: @@ -24,8 +24,6 @@ jobs: echo GITHUB_SHA=${{ github.sha }} >> .env - name: Build project run: npm run build - - name: Run Tests - run: export CI=true && npm run test -- --coverage - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/.github/workflows/Continuous_Deployment_Frontend_Prod.yml b/.github/workflows/Continuous_Deployment_Frontend_Prod.yml index 2aae4b72b..8d322afe9 100644 --- a/.github/workflows/Continuous_Deployment_Frontend_Prod.yml +++ b/.github/workflows/Continuous_Deployment_Frontend_Prod.yml @@ -1,4 +1,4 @@ -name: MasterDeployCI +name: MasterDeploy on: push: branches: @@ -24,8 +24,6 @@ jobs: echo GITHUB_SHA=${{ github.sha }} >> .env - name: Build project run: npm run build - - name: Run Tests - run: export CI=true && npm run test -- --coverage - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: