Skip to content

Commit

Permalink
add GitHub workflows for testing build and updating tabi
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Nov 27, 2024
1 parent 3aea7d5 commit 39609ce
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test build

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test:
name: Test Site Build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: true

- name: Zola Build
uses: shalzz/zola-deploy-action@v0.19.2
env:
BUILD_ONLY: true
76 changes: 76 additions & 0 deletions .github/workflows/update-tabi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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 theme
From: ${{ steps.check.outputs.old_version }}
To: ${{ steps.check.outputs.new_version }}
Update tabi to the latest version from https://github.com/welpo/tabi"
git push origin $BRANCH
gh pr create \
--title "⬆️ Update tabi theme" \
--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 }})
### Changelog
Submodule themes/tabi ${{ steps.check.outputs.old_version }}..${{ steps.check.outputs.new_version }}:
${{ steps.check.outputs.changelog }}
---
Auto-generated by the Update tabi theme workflow (in \`.github/workflows/update-tabi.yml\`)."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 39609ce

Please sign in to comment.