Build and Deploy #557
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 and Deploy | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
schedule: | |
- cron: "17 8 * * *" | |
workflow_dispatch: | |
jobs: | |
build: | |
name: "Build and Deploy" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
steps: | |
- name: Comment deploy start | |
if: github.event_name != 'push' | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message-id: cloudflare-deploy | |
message: | | |
### <span aria-hidden="true">🚧</span> Deploy Preview building... | |
| Name | Link | | |
|---------------------------------|------------------------| | |
|<span aria-hidden="true">🔨</span> Latest commit | ${{ github.sha }} | | |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | | |
--- | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: "package.json" | |
cache: "npm" | |
- run: npm ci | |
- uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: | | |
.cache | |
./img | |
dist/img/*.jpeg | |
dist/img/*.webp | |
key: 11ty-${{ runner.os }}-${{ github.run_id }} | |
restore-keys: | | |
11ty-${{ runner.os }} | |
${{ runner.os }}-11ty | |
- name: Build 11ty site | |
run: npm run build | |
env: | |
TINA_CLIENT_ID: ${{ secrets.TINA_CLIENT_ID }} | |
TINA_SEARCH_TOKEN: ${{ secrets.TINA_SEARCH_TOKEN }} | |
TINA_TOKEN: ${{ secrets.TINA_TOKEN }} | |
ENABLE_ANALYTICS: ${{ github.ref == 'refs/heads/master' }} | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
id: cloudflare | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: 8dfec48c278d5a97c93de33e072261bd | |
projectName: jonas-brusman-se | |
directory: dist | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.head_ref || github.ref_name }} | |
wranglerVersion: "3" | |
- name: Comment deploy url | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message-id: cloudflare-deploy | |
message: | | |
### <span aria-hidden="true">✅</span> Deploy Preview ready! | |
| Name | Link | | |
|---------------------------------|------------------------| | |
|<span aria-hidden="true">🔨</span> Latest commit | ${{ github.sha }} | | |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | | |
|<span aria-hidden="true">😎</span> Deploy Preview Url | [${{ steps.cloudflare.outputs.url }}](${{ steps.cloudflare.outputs.url }}) | | |
|<span aria-hidden="true">🌳</span> Environment | ${{ steps.cloudflare.outputs.environment }} | | |
--- | |
- uses: actions/cache/save@v4 | |
with: | |
path: | | |
.cache | |
./img | |
dist/img/*.jpeg | |
dist/img/*.webp | |
key: 11ty-${{ runner.os }}-${{ github.run_id }} |