Update tabi theme #98
This file contains hidden or 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: 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| 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 main changelog | |
| MAIN_CHANGELOG=$(git log --pretty=format:'- %s [%h](https://github.com/welpo/tabi/commit/%H)' $CURRENT..$NEW | \ | |
| grep -v -E '^- .*(misc|misc\([^)]+\)):' | \ | |
| sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/welpo\/tabi\/pull\/\1)/g') | |
| # Get misc changelog | |
| MISC_CHANGELOG=$(git log --pretty=format:'- %s [%h](https://github.com/welpo/tabi/commit/%H)' $CURRENT..$NEW | \ | |
| grep -E '^- .*(misc|misc\([^)]+\)):' | \ | |
| 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 "main_changelog<<CHANGELOG_DELIMITER" >> "$GITHUB_OUTPUT" | |
| echo "$MAIN_CHANGELOG" >> "$GITHUB_OUTPUT" | |
| echo "CHANGELOG_DELIMITER" >> "$GITHUB_OUTPUT" | |
| echo "misc_changelog<<MISC_DELIMITER" >> "$GITHUB_OUTPUT" | |
| echo "$MISC_CHANGELOG" >> "$GITHUB_OUTPUT" | |
| echo "MISC_DELIMITER" >> "$GITHUB_OUTPUT" | |
| fi | |
| cd ../.. | |
| - name: Zola Build | |
| if: steps.check.outputs.has_changes == 'true' | |
| uses: shalzz/zola-deploy-action@v0.22.0 | |
| env: | |
| BUILD_ONLY: true | |
| BUILD_THEMES: false | |
| - name: Commit and push to main | |
| if: steps.check.outputs.has_changes == 'true' | |
| run: | | |
| # Write commit message to file | |
| cat > commit_message.txt << 'EOF' | |
| ⬆️ Update tabi theme to ${{ steps.check.outputs.new_version }} | |
| Updating `themes/tabi` from ${{ steps.check.outputs.old_version }} to ${{ steps.check.outputs.new_version }}. | |
| ### Changelog | |
| ${{ steps.check.outputs.main_changelog }} | |
| EOF | |
| if [ ! -z "${{ steps.check.outputs.misc_changelog }}" ]; then | |
| cat >> commit_message.txt << 'EOF' | |
| ### Miscellaneous changes | |
| ${{ steps.check.outputs.misc_changelog }} | |
| EOF | |
| fi | |
| cat >> commit_message.txt << 'EOF' | |
| Auto-generated by the "Update tabi theme" workflow (in `.github/workflows/update-tabi.yml`). | |
| EOF | |
| git add themes/tabi | |
| git commit -F commit_message.txt | |
| rm commit_message.txt | |
| git push origin HEAD:main |