Update anki-sync-server version in values.yml (GH API) #59
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 anki-sync-server version in values.yml (GH API)" | |
# run workflow every monday at 00:00 UTC | |
on: | |
schedule: | |
- cron: "0 0 * * 1" | |
workflow_dispatch: | |
jobs: | |
update-version: | |
name: Update anki-sync-server version in values.yml | |
# use ubuntu as runner | |
runs-on: ubuntu-latest | |
# add GH token to secrets as GH_UPDATE_ANKI | |
# with write access to repository | |
# to allow workflow to write to repository | |
# | |
# normal GITHUB_TOKEN will not trigger the container-build workflow | |
# see here: <https://stackoverflow.com/a/73489863> | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_UPDATE_ANKI }} | |
- name: Setup yq | |
uses: mikefarah/yq@v4 | |
- name: Get current anki-sync-server version | |
id: set-op | |
run: | | |
echo "software-version=$(yq '.version.software-version' ./anki-sync-server/values.yml)" \ | |
>> $GITHUB_OUTPUT | |
- name: Fetch GH API and get tag_name from latest release | |
id: get-release | |
run: | | |
# get latest release a. extract tag_name | |
tag_name=$(curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/ankitects/anki/releases/latest |\ | |
yq '.tag_name') | |
# set output for later use | |
echo "name=$tag_name" >> $GITHUB_OUTPUT | |
- name: Set new anki-sync-server version in values.yml | |
if: ${{ steps.set-op.outputs.software-version != steps.get-release.outputs.name }} | |
run: | | |
yq -i '.version.software-version = "${{ steps.get-release.outputs.name }}"' \ | |
./anki-sync-server/values.yml | |
- name: Set up git email/name a. commit changes | |
if: ${{ steps.set-op.outputs.software-version != steps.get-release.outputs.name }} | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git add ./anki-sync-server/values.yml | |
git commit -m "chore(anki-sync-server): bump version to ${{ steps.get-release.outputs.name }}" | |
git push origin main |