Update tabi theme #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update tabi theme | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "5 0 * * 1" # Weekly on Mondays at 5 past midnight UTC | |
jobs: | |
update-tabi: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Check for updates | |
id: check | |
run: | | |
cd themes/tabi | |
CURRENT=$(git rev-parse HEAD) | |
git fetch | |
git checkout origin/main | |
NEW=$(git rev-parse HEAD) | |
if [ "$CURRENT" != "$NEW" ]; then | |
# Get the changelog with links to commits and PRs | |
CHANGELOG=$(git log --pretty=format:"- %s [%h](https://github.com/welpo/tabi/commit/%H)" $CURRENT..$NEW | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/welpo\/tabi\/pull\/\1)/g') | |
echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
echo "old_version=${CURRENT:0:7}" >> "$GITHUB_OUTPUT" | |
echo "new_version=${NEW:0:7}" >> "$GITHUB_OUTPUT" | |
echo "changelog<<EOF" >> "$GITHUB_OUTPUT" | |
echo "$CHANGELOG" >> "$GITHUB_OUTPUT" | |
echo "EOF" >> "$GITHUB_OUTPUT" | |
fi | |
cd ../.. | |
- name: Create Pull Request | |
if: steps.check.outputs.has_changes == 'true' | |
run: | | |
BRANCH="update-tabi-$(date +%Y%m%d-%H%M%S)" | |
git checkout -b $BRANCH | |
git add themes/tabi | |
git commit -m "⬆️ Update tabi | |
From: ${{ steps.check.outputs.old_version }} | |
To: ${{ steps.check.outputs.new_version }} | |
Update tabi to the latest version from https://github.com/welpo/tabi" | |
# Check for breaking changes. | |
if echo "${{ steps.check.outputs.changelog }}" | grep -E '^- (💥|.*!:)'; then | |
BREAKING_WARNING='> [!WARNING] | |
> This update includes breaking changes! Please review the changelog carefully before merging. | |
' | |
else | |
BREAKING_WARNING="" | |
fi | |
git push origin $BRANCH | |
gh pr create \ | |
--title "⬆️ Update tabi theme to ${{ steps.check.outputs.new_version }}" \ | |
--body "## Changes in this update | |
Updating \`themes/tabi\` from [\`${{ steps.check.outputs.old_version }}\`](https://github.com/welpo/tabi/commit/${{ steps.check.outputs.old_version }}) to [\`${{ steps.check.outputs.new_version }}\`](https://github.com/welpo/tabi/commit/${{ steps.check.outputs.new_version }}). | |
${BREAKING_WARNING}### Changelog | |
${{ steps.check.outputs.changelog }} | |
--- | |
Auto-generated by the Update tabi theme workflow (in \`.github/workflows/update-tabi.yml\`)." | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |