Skip to content

Commit a11a03d

Browse files
committed
Add workflow for automated builds upon new Anki releases
1 parent 1240507 commit a11a03d

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

.github/workflows/build-and-publish-image.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
branches:
66
- master
77
workflow_dispatch:
8-
inputs:
9-
parameter:
10-
description: Manual workflow run
118

129
env:
1310
REGISTRY: ghcr.io
@@ -44,6 +41,12 @@ jobs:
4441
with:
4542
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4643

44+
- name: Retrieve latest release version
45+
id: retrieve_latest_release_version
46+
run: |
47+
LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/ankitects/anki/releases/latest | jq -r '.tag_name')
48+
echo "latest_release_version=$LATEST_RELEASE_VERSION" >> $GITHUB_OUTPUT
49+
4750
- name: Build and push image
4851
uses: docker/build-push-action@v3
4952
with:
@@ -53,3 +56,14 @@ jobs:
5356
push: true
5457
tags: ${{ steps.meta.outputs.tags }}
5558
labels: ${{ steps.meta.outputs.labels }}
59+
60+
- name: Upload new release version as artifacts
61+
run: |
62+
echo "${{ steps.retrieve_latest_release_version.outputs.LATEST_RELEASE_VERSION }}" > anki-release-version
63+
64+
- name: Upload new artifacts
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: anki-release-version
68+
path: anki-release-version
69+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Thanks to:
2+
# https://stackoverflow.com/questions/58465057/trigger-a-github-action-when-another-repository-creates-a-new-release
3+
4+
name: Check for new Anki release
5+
6+
on:
7+
schedule:
8+
# triggered at 12:00 every day
9+
- cron: 0 12 * * *
10+
workflow-dispatch:
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
18+
- name: Download release version of last run
19+
id: download_last_release_version
20+
uses: dawidd6/action-download-artifact@v2
21+
with:
22+
name: anki-release-version
23+
workflow_conclusion: success
24+
workflow: check-anki-release.yml
25+
if_no_artifact_found: warn
26+
27+
- name: Retrieve latest release version
28+
id: retrieve_latest_release_version
29+
run: |
30+
LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/ankitects/anki/releases/latest | jq -r '.tag_name')
31+
echo "latest_release_version=$LATEST_RELEASE_VERSION" >> $GITHUB_OUTPUT
32+
33+
- name: Compare with last release version
34+
id: compare_release_version
35+
run: |
36+
LAST_RELEASE_VERSION=$(cat anki-release-version 2> /dev/null || echo "NOT FOUND")
37+
38+
if [ "${{ steps.retrieve_latest_release_version.outputs.LATEST_RELEASE_VERSION }}" != "$LAST_RELEASE_VERSION" ]; then
39+
echo "release_version_changed=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "release_version_changed=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Trigger build and publish workflow
45+
if: steps.compare_release.outputs.release_version_changed == 'true'
46+
uses: benc-uk/workflow-dispatch@v1
47+
with:
48+
workflow: build-and-publish-image.yml

0 commit comments

Comments
 (0)