Skip to content

Update anki version in values.yml #23

Update anki version in values.yml

Update anki version in values.yml #23

# SPDX-FileCopyrightText: 2023 Frederik Zorn <federdaemn@mail.de>
#
# SPDX-License-Identifier: Apache-2.0
name: 'Update anki version in values.yml'
# run workflow every monday at 00:00 UTC
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
update-version:
name: Update anki version in values.yml
# use ubuntu as runner
runs-on: ubuntu-latest
# add GH token to secrets as GH_ANKI_VERSION_TOKEN
# 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_ANKI_VERSION_TOKEN }}
- name: Setup yq
uses: mikefarah/yq@v4
- name: Get current anki version
id: anki-version
run: |
echo "anki-version=$(yq '.version.anki-version' ./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 version in values.yml
if: ${{ steps.anki-version.outputs.anki-version != steps.get-release.outputs.name }}
run: |
yq -i '.version.anki-version = "${{ steps.get-release.outputs.name }}"' \
./values.yml
- name: Set up git email/name a. commit changes
if: ${{ steps.anki-version.outputs.anki-version != steps.get-release.outputs.name }}
run: |
git config user.name federdaemn-bot
git config user.email federdaemn@mail.de
git add ./values.yml
git commit -m "chore(anki): bump anki version to ${{ steps.get-release.outputs.name }}" \
-m "Signed-off-by: github-actions in the name of Frederik Zorn <federdaemn@mail.de>"
git push origin main