Add optional step to deploy PRs to netlify #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
name: Test Build | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
- name: Install dependencies | |
run: npm ci --no-scripts | |
- name: Build site | |
run: npm run build | |
- name: Send bundle stats to RelativeCI | |
uses: relative-ci/agent-action@v2 | |
with: | |
webpackStatsFile: ./webpack-stats.json | |
key: ${{ secrets.RELATIVE_CI_KEY }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Zip up the public directory | |
run: cd public && zip -r ../site.zip ./ | |
- name: Upload zipped site as an artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: site | |
path: site.zip | |
- name: Determine the size of the zip file | |
id: determineSize | |
# Save to GITHUB_OUTPUT | |
run: echo "SIZE=$(du -sh site.zip | cut -f1)" >> $GITHUB_OUTPUT | |
- name: Create a neutral check with the zipped size | |
uses: LouisBrunner/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: "Build Size" | |
conclusion: neutral | |
output: | | |
{"title":"${{ steps.determineSize.outputs.SIZE }} (of 5M)","summary":"${{ steps.determineSize.outputs.SIZE }} (of 5M)"} | |
- name: Upload to netlify (if a PR build) | |
if: github.event_name == 'pull_request' | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: ./public | |
production-deploy: false | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: ${{ github.event.pull_request.title }}) | |
enable-pull-request-comment: true | |
enable-commit-comment: false | |
enable-commit-status: true | |
overwrites-pull-request-comment: true | |
# replicate deploy preview prefix (ish) | |
alias: deploy-preview-pr-${{ github.event.pull_request.number }} | |
enable-github-deployment: false |