Skip to content

Deployment (Prod - New Bucket) #50

Deployment (Prod - New Bucket)

Deployment (Prod - New Bucket) #50

name: 'Deployment (Prod - New Bucket)'
on:
#push:
# branches:
# - 'prod'
workflow_dispatch:
jobs:
Docusaurus:
name: 'Deployment'
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@master
with:
find: ${{ secrets.CDN_URL }}
replace: ${{ secrets.PROD_WEBSITE_URL }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@master
with:
find: "indexName: '${{ secrets.STAGE_INDEX }}',"
replace: "indexName: '${{ secrets.PROD_INDEX }}',"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_MKT }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_MKT }}
aws-region: us-east-1
- name: 'Create env file'
run: |
touch .env
echo "HOST=${{ secrets.TYPESENSE_HOST }}" >> .env
echo "API=${{ secrets.PUBLIC_APY_TYPESENSE }}" >> .env
- name: Use Node.js 16.14.x
uses: actions/setup-node@v3
with:
node-version: 16.14.x
- run: npm install --legacy-peer-deps && npm run build
env:
CI: false
- name: Copy files to S3 with the AWS CLI
run: |
cp -R assets/ build/
cd build/
aws s3 sync . s3://lambdatest-prod-docs/support/ --exclude 'robots.txt' --delete
- name: Invalidate Cloudfront
run : |
aws cloudfront create-invalidation --distribution-id EEMGB6PM4ZZ7A --paths "/support/*"
sleep 90
- name: Cloudflare Invalidation
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache" -H "X-Auth-Email: ${{ secrets.CF_ACCOUNT }}" -H "X-Auth-Key: ${{ secrets.CF_API_SECRET }}" -H "Content-Type: application/json" --data '{"hosts":["${{ secrets.PROD_WEBSITE_URL }}"] }'
sleep 60