Skip to content

Update cover image in a blog post #70

Update cover image in a blog post

Update cover image in a blog post #70

Workflow file for this run

name: Update cover image in a blog post
on:
workflow_dispatch:
inputs:
date_slug_combo:
type: string
description: Date slug combo to use for this content build step
required: true
commit_message:
type: string
description: Commit message to use for this content build step
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
fetch-and-commit-image:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Fetch image from R2
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: r2 object get ${{ secrets.R2_BUCKET_NAME }}/blog/cover/${{ inputs.date_slug_combo }}/image.webp --file src/content/blog/${{ inputs.date_slug_combo }}/image.webp
wranglerVersion: '3.80.1'
- name: Check for changes
id: check_changes
run: |
git add .
git diff --staged --quiet || echo "CHANGES_EXIST=true" >> $GITHUB_OUTPUT
- name: Commit Changes
if: steps.check_changes.outputs.CHANGES_EXIST == 'true'
uses: planetscale/ghcommit-action@v0.1.33
with:
commit_message: ${{ github.event.inputs.commit_message || 'Update cover image in blog post' }}
repo: ${{ github.repository }}
branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report-status:
needs: fetch-and-commit-image
if: failure()
runs-on: ubuntu-latest
steps:
- name: Report failure
run: |
echo "Failed to update cover image in blog post"
exit 1