Skip to content

Commit

Permalink
DO-4183 adding pr test and gated env deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeD42 committed Jul 28, 2023
1 parent c15640e commit f0563a2
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
65 changes: 60 additions & 5 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Build and Deploy to S3
name: Build and Deploy

on:
push:
branches:
- main

jobs:
build_and_deploy:
build_artifact:
runs-on: ubuntu-latest
environment: dev

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -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/<INDEX_NAME>/${{ vars.ALGOLIA_INDEX }}/g' algolia.json
sed -i 's/<FQDN>/${{ 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
Expand All @@ -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: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f0563a2

Please sign in to comment.