Update submodules (theme) #14
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 submodules (theme) | |
# Controls when the action will run. | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
# This workflow contains a single job called "update" | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
- name: Commit, push changes & open PR | |
run: | | |
DATE=$(date '+%Y%m%d-%H%M') | |
BRANCH_NAME="update-submodules/update-$DATE" | |
SOURCE_REPO="https://github.com/zetxek/adritian-free-hugo-theme" | |
# Setup the committers identity. | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions - update theme submodule" | |
git checkout -b $BRANCH_NAME | |
git submodule update --init --recursive | |
git submodule update --recursive --remote | |
git commit -am "Update submodules" | |
git push origin $BRANCH_NAME | |
LATEST_TAG=$(git --git-dir=themes/adritian-free-hugo-theme/.git describe --tags --always) | |
LAST_COMMIT=$(git submodule status | awk '{print $1}') | |
echo "Creating pull-request..." | |
PR_TITLE='update theme to `'$LATEST_TAG'`' | |
echo 'PR title: '$PR_TITLE | |
PR_BODY='🤖 This automated PR updates the theme submodule: '$SOURCE_REPO'. | |
👉 Last commit: `'$LAST_COMMIT'` | |
🔗 Triggered by a github action: https://github.com/zetxek/adrianmoreno.info/actions/workflows/update-submodules.yml' | |
echo "PR body: "$PR_BODY | |
gh pr create \ | |
-B main \ | |
-H $BRANCH_NAME \ | |
--title "$PR_TITLE" \ | |
--body "$PR_BODY" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |