From 39609ce39216c3c51fddbfbdad5d3db6df6edbc2 Mon Sep 17 00:00:00 2001 From: welpo Date: Wed, 27 Nov 2024 02:18:28 +0100 Subject: [PATCH] add GitHub workflows for testing build and updating tabi --- .github/workflows/test-build.yml | 22 +++++++++ .github/workflows/update-tabi.yml | 76 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 .github/workflows/test-build.yml create mode 100644 .github/workflows/update-tabi.yml diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..05f0c76 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -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 diff --git a/.github/workflows/update-tabi.yml b/.github/workflows/update-tabi.yml new file mode 100644 index 0000000..5386fc3 --- /dev/null +++ b/.github/workflows/update-tabi.yml @@ -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<> "$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 }}