Hugo release version bump #652
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: Hugo release version bump | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
env: | |
GIT_DISCOVERY_ACROSS_FILESYSTEM: "true" | |
jobs: | |
update: | |
runs-on: floryn90-runners | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
- name: Install build essential | |
uses: ./.github/actions/install_deps | |
- name: Check latest release tag | |
id: hugo_tag | |
shell: bash | |
run: | | |
releases=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/gohugoio/hugo/releases?per_page=1&page=1) | |
release_tag=$(echo $releases | jq '.[0].tag_name' | sed 's/v//' | sed 's/"//g') | |
echo "Latest release tag of gohugoio/hugo is ${release_tag}" | |
echo "hugo_latest_release_tag=${release_tag}" >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
- name: Identify latest release tag | |
shell: bash | |
run: | | |
releases=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/releases?per_page=1&page=1) | |
my_release_tag=$(echo $releases | jq '.[0].tag_name' | sed 's/v//' | sed 's/"//g') | |
echo "My latest release tag is ${my_release_tag}" | |
echo "my_release_tag=${my_release_tag}" >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
- name: Configure Git User's information | |
shell: bash | |
run: | | |
git config --global user.email '[email protected]' | |
git config --global user.name 'Florin Lungu' | |
- name: Create new release branch and run version bump | |
if: env.my_release_tag != env.hugo_latest_release_tag | |
shell: bash | |
run: | | |
git checkout -b release/${{ env.hugo_latest_release_tag }} | |
version=${{env.hugo_latest_release_tag}} make bump | |
git add -A | |
git reset -- github_token.txt | |
git commit -m "hugo version bump to ${{env.hugo_latest_release_tag}}" | |
git push origin release/${{env.hugo_latest_release_tag}}:release/${{env.hugo_latest_release_tag}} | |
- name: Create new PR with latest release branch | |
id: pr | |
if: env.my_release_tag != env.hugo_latest_release_tag | |
shell: bash | |
run: | | |
pr=$(gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/pulls -f title="Hugo version bump to ${{env.hugo_latest_release_tag}}" -f body="Hugo version bump to ${{env.hugo_latest_release_tag}}" -f head="release/${{env.hugo_latest_release_tag}}" -f base='master') | |
pr_number=$(echo $pr | jq '.number') | |
echo "pr_number=${pr_number}" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
- name: Merge the PR | |
if: env.my_release_tag != env.hugo_latest_release_tag | |
shell: bash | |
run: | | |
gh api --method PUT -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/pulls/${{ steps.pr.outputs.pr_number }}/merge -f commit_title="Merge PR ${{ steps.pr.outputs.pr_number }}" -f commit_message='Merge pull request to upgrade hugo version' | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
- name: Create new release tag | |
if: env.my_release_tag != env.hugo_latest_release_tag | |
shell: bash | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/floryn90/docker-hugo/releases -f tag_name="v${{ env.hugo_latest_release_tag }}" -f target_commitish='master' -f name="Hugo version v${{env.hugo_latest_release_tag}}" -f body="Hugo release version bump to ${{env.hugo_latest_release_tag}}" -F draft=false -F prerelease=false -F generate_release_notes=true | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_GITHUB }} |