From f0563a2cef311c01a644d06bcb26c3b8ad1f29e8 Mon Sep 17 00:00:00 2001 From: Michael Stettenbenz Date: Fri, 28 Jul 2023 18:10:47 -0400 Subject: [PATCH 1/3] DO-4183 adding pr test and gated env deploy --- .github/workflows/build-and-deploy.yml | 65 ++++++++++++++++++++++++-- .github/workflows/test-build.yml | 26 +++++++++++ 2 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test-build.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index d4dd8b8d..34c1060d 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,4 +1,4 @@ -name: Build and Deploy to S3 +name: Build and Deploy on: push: @@ -6,10 +6,8 @@ on: - main jobs: - build_and_deploy: + build_artifact: runs-on: ubuntu-latest - environment: dev - steps: - name: Checkout code uses: actions/checkout@v2 @@ -24,6 +22,63 @@ jobs: - name: Build run: yarn build + + - name: Archive build + uses: actions/upload-artifact@v3 + with: + name: yarn-${{ github.sha }} + path: build + +jobs: + deploy_dev: + needs: build_artifact + runs-on: ubuntu-latest + environment: dev + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: yarn-${{ github.sha }} + + - 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 # Replace with your AWS region + + - name: Sync to S3 + run: aws s3 sync build/ s3://${{ vars.S3_BUCKET }} --size-only --delete + + - name: Invalidate CF cache + run: | + INVAL_ID=$(aws cloudfront create-invalidation --distribution-id ${{ vars.CF_DISTRO }} --paths "/*" | jq -r .Invalidation.Id ) + aws cloudfront wait invalidation-completed --distribution-id ${{ vars.CF_DISTRO }} --id $INVAL_ID + + - name: Setup Algolia Config + id: algolia_config + run: | + sed -i 's//${{ vars.ALGOLIA_INDEX }}/g' algolia.json + sed -i 's//${{ vars.FQDN }}/g' algolia.json + echo "::set-output name=config::$(cat algolia.json | jq -r tostring)" + + - name: Run Algolia Reindex + uses: signcl/docsearch-scraper-action@master + env: + APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }} + API_KEY: ${{ secrets.ALGOLIA_API_KEY }} + CONFIG: ${{ steps.algolia_config.outputs.config }} + +jobs: + deploy_stg: + needs: deploy_dev + runs-on: ubuntu-latest + environment: stg + steps: + name: Download artifact + uses: actions/download-artifact@v3 + with: + name: yarn-${{ github.sha }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 @@ -33,7 +88,7 @@ jobs: aws-region: us-east-1 # Replace with your AWS region - name: Sync to S3 - run: aws s3 sync build/ s3://device42-docs-website-content-dev --size-only --delete + run: aws s3 sync build/ s3://${{ vars.S3_BUCKET }} --size-only --delete - name: Invalidate CF cache run: | diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 00000000..21781e0a --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,26 @@ +name: PR build test + +on: + pull_request: + branches: + - main + +jobs: + test_build: + name: Test build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '16.14' + + - name: Install Dependencies + run: yarn + + - name: Build + run: yarn build From f717436fcd4ae2ba4dbf1ecad31a5277c03d5b48 Mon Sep 17 00:00:00 2001 From: Michael Stettenbenz Date: Fri, 28 Jul 2023 18:14:25 -0400 Subject: [PATCH 2/3] DO-4183 format error --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 34c1060d..cedd0d90 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest environment: stg steps: - name: Download artifact + - name: Download artifact uses: actions/download-artifact@v3 with: name: yarn-${{ github.sha }} From 65fd8aff4b65c8f5cd2d0c189723529d18500a16 Mon Sep 17 00:00:00 2001 From: Michael Stettenbenz Date: Fri, 28 Jul 2023 18:15:39 -0400 Subject: [PATCH 3/3] DO-4183 more format errors --- .github/workflows/build-and-deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index cedd0d90..1089b246 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -29,7 +29,6 @@ jobs: name: yarn-${{ github.sha }} path: build -jobs: deploy_dev: needs: build_artifact runs-on: ubuntu-latest @@ -69,7 +68,6 @@ jobs: API_KEY: ${{ secrets.ALGOLIA_API_KEY }} CONFIG: ${{ steps.algolia_config.outputs.config }} -jobs: deploy_stg: needs: deploy_dev runs-on: ubuntu-latest