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"