-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (85 loc) · 3.47 KB
/
external-trigger.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Check for new version
on:
schedule:
- cron: "*/20 * * * *"
push:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
actions: write
jobs:
check_new_version:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.check_version.outputs.new_version }}
immich_version: ${{ steps.check_version.outputs.immich_version }}
current_version: ${{ steps.check_version.outputs.current_version }}
steps:
- uses: actions/checkout@v4
- name: Check if new version is available
id: check_version
run: |
current_version=$(curl -sL https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest | jq -r '.tag_name')
immich_version=$(curl -sL https://api.github.com/repos/immich-app/immich/releases/latest | jq -r '.tag_name')
if [[ "$current_version" == "null" || "$immich_version" == "null" ]]; then
echo "new_version=false" >> $GITHUB_OUTPUT
fi
if [ "$current_version" != "$immich_version" ]; then
if git tag | grep -q "^$immich_version$"; then
echo "Tag '$immich_version' exists."
else
echo "New immich version ($immich_version) detected."
echo "current_version=$current_version" >> $GITHUB_OUTPUT
echo "immich_version=$immich_version" >> $GITHUB_OUTPUT
echo "new_version=true" >> $GITHUB_OUTPUT
exit 0
fi
else
echo "Immich version ($immich_version) already exists"
fi
echo "new_version=false" >> $GITHUB_OUTPUT
create_new_version:
if: ${{ needs.check_new_version.outputs.new_version == 'true' }}
runs-on: ubuntu-latest
needs: [check_new_version]
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
run: |
git tag "${{ needs.check_new_version.outputs.immich_version }}"
git push --tags
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ needs.check_new_version.outputs.immich_version }} \
--generate-notes \
--notes "Read Immich release notes [here](https://github.com/immich-app/immich/releases/tag/${{ needs.check_new_version.outputs.immich_version }})"
- name: Get base image tag
id: tag
run: |
mkdir /tmp/immich
curl -o \
/tmp/immich.tar.gz -L \
"https://github.com/immich-app/immich/archive/${{ needs.check_new_version.outputs.immich_version }}.tar.gz" && \
tar xf \
/tmp/immich.tar.gz -C \
/tmp/immich --strip-components=1 && \
dockerfile_content=$(cat /tmp/immich/server/Dockerfile)
date=$(echo "$dockerfile_content" | grep -oP 'base-server-prod:\K\d{8}')
if [ -z "$date" ]; then
base_image_tag="latest";
else
base_image_tag="$date";
fi
echo "base_image_tag=${base_image_tag}" >> $GITHUB_OUTPUT
- name: Trigger workflow
if: github.event_name != 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run docker.yml -f version=${{ needs.check_new_version.outputs.immich_version }} -f base_image_tag=${{ steps.tag.outputs.base_image_tag }}