1
Evan Pratten cee3c03b92 Automatically add workflow info to commit notes
This commit adds the GitHub Actions workflow run URL to the notes area
of each commit that is processed by the CI pipeline.

This shall be used in a blog post later.
2024-05-12 09:16:41 -04:00

83 lines
2.4 KiB
YAML

name: Build & Deploy Site
on:
push:
jobs:
workflow_note:
name: Workflow Note
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Add a note with info about this workflow
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin "refs/notes/*:refs/notes/*"
git notes append -m "GH-Actions-Workflow-Run: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
git push origin "refs/notes/*:refs/notes/*"
build_dev:
name: Development Build
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
deployments: write
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Write the commit hash into the config
run: echo "commit = \"$(git rev-parse HEAD | cut -c1-7)\"" >> config.toml
- name: Build only
uses: shalzz/zola-deploy-action@v0.18.0
env:
BUILD_ONLY: true
BUILD_FLAGS: --drafts
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ewpratten
directory: public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '2'
build_prod:
name: Production Build
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
deployments: write
steps:
- name: Checkout master
uses: actions/checkout@v4
- name: Write the commit hash into the config
run: echo "commit = \"$(git rev-parse HEAD | cut -c1-7)\"" >> config.toml
- name: Build only
uses: shalzz/zola-deploy-action@v0.18.0
env:
BUILD_ONLY: true
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ewpratten
directory: public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '2'