From 3ca5fce8f386737a25a1f860aced08ca26fbc75a Mon Sep 17 00:00:00 2001 From: William Horn Date: Thu, 20 Jun 2024 08:13:29 -0800 Subject: [PATCH] feat: add github actions for test deployment --- .github/workflows/deploy-prod.yml | 21 +++++++ .github/workflows/deploy-test.yml | 25 ++++++++ .../workflows/search-ui-composite/action.yml | 60 +++++++++++++++++++ buildspec.yml | 2 +- 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-prod.yml create mode 100644 .github/workflows/deploy-test.yml create mode 100644 .github/workflows/search-ui-composite/action.yml diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml new file mode 100644 index 000000000..5e6d779a0 --- /dev/null +++ b/.github/workflows/deploy-prod.yml @@ -0,0 +1,21 @@ +name: Update BulkDownload Stack (prod) + +on: + push: + branches: + - prod + +jobs: + deploy: + runs-on: ubuntu-latest + environment: test + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: build + uses: ./.github/workflows/bulk-download-deploy-composite + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml new file mode 100644 index 000000000..ce9caab4c --- /dev/null +++ b/.github/workflows/deploy-test.yml @@ -0,0 +1,25 @@ +name: Update BulkDownload Stack (test) + +on: + push: + branches: + - actions + +jobs: + deploy: + runs-on: ubuntu-latest + environment: test + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: build + uses: ./.github/workflows/bulk-download-deploy-composite + with: + maturity: test + application: ${{ vars.APPLICATION }} + cdn-id: ${{ vars.CDN_ID }} + s3-bucket: ${{ vars.S3_BUCKET }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/search-ui-composite/action.yml b/.github/workflows/search-ui-composite/action.yml new file mode 100644 index 000000000..990ba8c75 --- /dev/null +++ b/.github/workflows/search-ui-composite/action.yml @@ -0,0 +1,60 @@ +name: Composite search-ui deploy action + +inputs: + maturity: + required: true + type: string + application: + required: true + type: string + cdn-id: + required: true + type: string + s3-bucket: + required: true + type: string + aws-access-key-id: + required: true + type: string + aws-secret-access-key: + required: true + type: string + +runs: + using: "composite" + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies + shell: bash + run: | + cp src/app/services/envs/env-${{ inputs.maturity }}.ts src/app/services/env.ts + echo "{\"hash\":\"${{ github.sha }}\"}" > src/assets/commit-hash.json + npm install -g @angular/cli@17.2.7 + npm install + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ inputs.aws-access-key-id }} + aws-secret-access-key: ${{ inputs.aws-secret-access-key }} + aws-region: "us-east-1" + + - name: Angular Build + run: | + ng build --configuration production + + - name: Deploy to AWS + shell: bash + run: | + cd dist/${{ inputs.application }} + aws s3 sync . "s3://${{ inputs.s3-bucket }}" + aws cloudfront create-invalidation \ + --distribution-id ${{ inputs.cdn-id }} \ + --paths /index.html /manifest.json /ngsw.json /favicon.ico /assets/i18n/* /assets/* /docs/* diff --git a/buildspec.yml b/buildspec.yml index b3973eafd..17d627cd3 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -7,7 +7,7 @@ phases: commands: - n 18 - npm set progress=false - - npm install -g @angular/cli@15.2.7 + - npm install -g @angular/cli@17.2.7 pre_build: commands: - cp src/app/services/envs/env-${MATURITY}.ts src/app/services/env.ts