|
| 1 | +name: Deploy to docs-content.arduino.cc |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: deploy-production |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + id-token: write |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + if: "github.repository == 'arduino/docs-content'" |
| 20 | + runs-on: ubuntu-latest |
| 21 | + environment: production |
| 22 | + env: |
| 23 | + REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} |
| 24 | + APP_ENV: prod |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + - uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: 18 |
| 33 | + cache: "npm" |
| 34 | + cache-dependency-path: "**/package-lock.json" |
| 35 | + |
| 36 | + - name: Render Datasheets |
| 37 | + run: cd ${GITHUB_WORKSPACE}/scripts/datasheet-rendering;./render-datasheets.sh |
| 38 | + |
| 39 | + - name: Copy Static Files |
| 40 | + run: | |
| 41 | + mkdir -p static/resources/datasheets static/resources/schematics static/resources/pinouts |
| 42 | + find ./content/hardware -type f -name "*-schematics.pdf" -exec cp {} ./static/resources/schematics/ \; |
| 43 | + find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \; |
| 44 | + find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \; |
| 45 | + find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \; |
| 46 | + find ./content/hardware -type f -name "*-step.zip" -exec cp {} ./static/resources/models/ \; |
| 47 | +
|
| 48 | + - name: Gatsby main cache |
| 49 | + uses: actions/cache@v4 |
| 50 | + id: gatsby-cache-folder |
| 51 | + with: |
| 52 | + path: .cache |
| 53 | + key: ${{ runner.os }}-cache-gatsby-${{ github.sha }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-cache-gatsby- |
| 56 | +
|
| 57 | + - name: Gatsby Public Folder |
| 58 | + uses: actions/cache@v4 |
| 59 | + id: gatsby-public-folder |
| 60 | + with: |
| 61 | + path: public/ |
| 62 | + key: ${{ runner.os }}-public-gatsby-${{ github.sha }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-public-gatsby- |
| 65 | +
|
| 66 | + - run: npm install |
| 67 | + - run: npm run build |
| 68 | + |
| 69 | + - name: Configure AWS credentials from Production account |
| 70 | + uses: aws-actions/configure-aws-credentials@v4 |
| 71 | + with: |
| 72 | + role-to-assume: ${{ secrets.PRODUCTION_IAM_ROLE }} |
| 73 | + aws-region: us-east-1 |
| 74 | + |
| 75 | + - name: Sync all cacheable assets |
| 76 | + 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.PRODUCTION_BUCKET_NAME }}/ |
| 77 | + |
| 78 | + - name: Sync all non-cacheable assets |
| 79 | + # Don't cache any HTML or JSON file: they should always be up-to-dates |
| 80 | + 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.PRODUCTION_BUCKET_NAME }}/ |
0 commit comments