ci(sync): add automated git-cliff version sync (#75)

* ci: add workflow to sync git-cliff version with upstream releases

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* ci: change git-cliff sync schedule to weekly

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* fix: remove redundant step

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* fix: remove obsolete api call

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* fix: rename branch name

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* chore: add comment on crontab

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* feat: add README.md inplace replacement

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* chore: enable strict shell mode in workflow steps

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* chore: add pr body

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* refactor: make variable expansion consistent

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* refactor: use sed instead of yq for replacement

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

* revert: newline replacement

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>

---------

Signed-off-by: Shingo OKAWA <shingo.okawa.g.h.c@gmail.com>
This commit is contained in:
Shingo OKAWA
2026-02-28 19:43:34 +09:00
committed by GitHub
parent c93ef52f3d
commit 07dda38699

View File

@@ -0,0 +1,69 @@
name: Sync git-cliff version
on:
schedule:
- cron: '0 3 * * 1' # every Monday at 03:00 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
check:
name: Check
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest git-cliff release
id: latest
run: |
set -euo pipefail
VERSION=$(curl -s https://api.github.com/repos/orhun/git-cliff/releases/latest | jq -r .tag_name)
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
- name: Read current default version
id: current
run: |
set -euo pipefail
VERSION=$(yq '.inputs.version.default' action.yml)
echo "version=${VERSION}" >> ${GITHUB_OUTPUT}
- name: Bump version
if: steps.latest.outputs.version != steps.current.outputs.version
env:
CURRENT: ${{ steps.current.outputs.version }}
LATEST: ${{ steps.latest.outputs.version }}
run: |
set -euo pipefail
sed -i "s|${CURRENT}|${LATEST}|g" action.yml
sed -i "s|${CURRENT}|${LATEST}|g" README.md
- name: Create PR
if: steps.latest.outputs.version != steps.current.outputs.version
env:
LATEST: ${{ steps.latest.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
BRANCH="chore/git-cliff-${LATEST}"
TITLE="chore: bump git-cliff to ${LATEST}"
BODY="This PR bumps git-cliff to ${LATEST}.
🔗 https://github.com/orhun/git-cliff/releases/tag/${LATEST}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B "${BRANCH}"
git add action.yml
git add README.md
git commit -m "${TITLE}" || echo "Nothing to commit"
git push origin "${BRANCH}" --force
echo "${GITHUB_TOKEN}" | gh auth login --with-token
gh pr create \
--base main \
--head "${BRANCH}" \
--title "${TITLE}" \
--body "${BODY}" \
|| echo "PR already exists"