Skip to content

Update Hugo

Update Hugo #168

Workflow file for this run

---
name: Update Hugo
on:
workflow_dispatch:
schedule:
- cron: '0 5 * * 1-5' # https://crontab.guru/#0_5_*_*_1-5 "At 05:00 every day-of-week from Monday through Friday."
jobs:
update_hugo:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
file: .github/workflows/publish.yaml
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Hugo
id: versions
run: |
set -o pipefail
CURRENT=$(yq -r '.jobs.build.env[]' ${{ env.file }})
echo "Current version of Hugo in publish.yaml is $CURRENT"
LATEST=$(curl -s -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/gohugoio/hugo/releases/latest" \
| jq -r '.tag_name')
LATEST_SEMVER="${LATEST#v}"
echo "Latest version of Hugo is $LATEST_SEMVER"
sed -i "s/HUGO_VERSION:.*/HUGO_VERSION: $LATEST_SEMVER/" "${{ env.file }}"
git diff
{
echo "current=$CURRENT"
echo "latest=$LATEST_SEMVER"
} >> "$GITHUB_OUTPUT"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
env:
bot_name: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
message: "chore(action): bump hugo from ${{ steps.versions.outputs.current }} to ${{ steps.versions.outputs.latest }}"
hugo_url: https://github.com/gohugoio/hugo
with:
token: ${{ secrets.PAT }} # to be able to update a workflow
branch: chore/action/update-hugo-version
delete-branch: true
committer: ${{ env.bot_name }}
author: ${{ env.bot_name }}
commit-message: ${{ env.message }}
title: ${{ env.message }}
labels: dependencies
body: |
Bump [Hugo](${{ env.hugo_url }}) from ${{ steps.versions.outputs.current }} to ${{ steps.versions.outputs.latest }}
---
Release: ${{ env.hugo_url }}/releases/tag/v${{ steps.versions.outputs.latest }}
Changelog: ${{ env.hugo_url }}/compare/v${{ steps.versions.outputs.current }}...v${{ steps.versions.outputs.latest }}