From 07dda386992489f0a6151dee53f3a137713644de Mon Sep 17 00:00:00 2001 From: Shingo OKAWA Date: Sat, 28 Feb 2026 19:43:34 +0900 Subject: [PATCH] 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 * ci: change git-cliff sync schedule to weekly Signed-off-by: Shingo OKAWA * fix: remove redundant step Signed-off-by: Shingo OKAWA * fix: remove obsolete api call Signed-off-by: Shingo OKAWA * fix: rename branch name Signed-off-by: Shingo OKAWA * chore: add comment on crontab Signed-off-by: Shingo OKAWA * feat: add README.md inplace replacement Signed-off-by: Shingo OKAWA * chore: enable strict shell mode in workflow steps Signed-off-by: Shingo OKAWA * chore: add pr body Signed-off-by: Shingo OKAWA * refactor: make variable expansion consistent Signed-off-by: Shingo OKAWA * refactor: use sed instead of yq for replacement Signed-off-by: Shingo OKAWA * revert: newline replacement Signed-off-by: Shingo OKAWA --------- Signed-off-by: Shingo OKAWA --- .github/workflows/sync-git-cliff-version.yml | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/sync-git-cliff-version.yml diff --git a/.github/workflows/sync-git-cliff-version.yml b/.github/workflows/sync-git-cliff-version.yml new file mode 100644 index 0000000..a0f95c9 --- /dev/null +++ b/.github/workflows/sync-git-cliff-version.yml @@ -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"