From 7e0a58b31f0a88a93cf7ebcca8277ac52bc572a9 Mon Sep 17 00:00:00 2001 From: Luca Osti Date: Wed, 26 Jan 2022 11:46:46 +0100 Subject: [PATCH] Deploy to production --- .github/workflows/deploy-prd.yml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/deploy-prd.yml diff --git a/.github/workflows/deploy-prd.yml b/.github/workflows/deploy-prd.yml new file mode 100644 index 0000000000..8a21fdc24e --- /dev/null +++ b/.github/workflows/deploy-prd.yml @@ -0,0 +1,56 @@ +name: Deploy to production + +on: + workflow_dispatch: + +jobs: + build: + if: "github.repository == 'arduino/docs-content'" + runs-on: ubuntu-latest + env: + REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} + APP_ENV: prod + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + cache: "npm" + cache-dependency-path: "**/package-lock.json" + + - name: Gatsby main cache + uses: actions/cache@v1 + id: gatsby-cache-folder + with: + path: .cache + key: ${{ runner.os }}-cache-gatsby-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-cache-gatsby- + + - name: Gatsby Public Folder + uses: actions/cache@v1 + id: gatsby-public-folder + with: + path: public/ + key: ${{ runner.os }}-public-gatsby-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-public-gatsby- + + - run: npm install + + - run: npm run build + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-1 + + - name: Sync all cacheable assets + run: + aws s3 sync --cache-control "public, max-age=31536000, immutable" --include "*.css" --include="*.js" --include="*.gif" --include="*.png" --include="*.svg" --exclude "*.html" --exclude="sw.js" --exclude="*.json" --delete public/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/ + # Don't cache any HTML or JSON file: they should always be up-to-date + - name: Sync all non-cacheable assets + run: aws s3 sync --cache-control "public, max-age=0, must-revalidate" --include "*.html" --include="sw.js" --include="*.json" --include "*.css" --exclude="*.js" --exclude="*.gif" --exclude="*.png" --exclude="*.svg" --delete public/ s3://${{ secrets.PROD_AWS_S3_BUCKET_NAME }}/