Skip to content

Commit d30db4d

Browse files
authored
Update Custom_Build.yml
1 parent 33929b3 commit d30db4d

1 file changed

Lines changed: 57 additions & 51 deletions

File tree

.github/workflows/Custom_Build.yml

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,97 @@
1-
name: Sync and Build Immich Images
1+
# .github/workflows/sync-and-build.yml
2+
name: Sync Immich Release & Build Images
23

34
on:
45
schedule:
5-
- cron: '0 * * * *' # Runs every hour
6+
# every hour; adjust as you like
7+
- cron: '0 * * * *'
68
workflow_dispatch:
79

810
permissions:
9-
contents: write
10-
packages: write
11+
contents: write # to update branches
12+
packages: write # to push to GHCR
13+
actions: read
1114

1215
jobs:
13-
sync-and-build:
16+
sync:
1417
runs-on: ubuntu-latest
15-
env:
16-
GHCR_REPO: ghcr.io/${{ github.repository_owner }}
18+
# expose the fetched tag to downstream jobs
19+
outputs:
20+
release_tag: ${{ steps.get_release.outputs.tag }}
1721
steps:
18-
- name: Checkout target repo
22+
- name: Get latest Immich release tag
23+
id: get_release
24+
uses: actions/github-script@v6
25+
with:
26+
script: |
27+
const latest = await github.rest.repos.getLatestRelease({
28+
owner: 'immich-app',
29+
repo: 'immich',
30+
});
31+
return latest.data.tag_name;
32+
result-encoding: string
33+
# now get_release.outputs.tag == e.g. "v1.134.0"
34+
35+
- name: Check out this repo
1936
uses: actions/checkout@v4
2037
with:
21-
ref: dockerimageML
38+
fetch-depth: 0 # we need full history to push branches/tags
2239

23-
- name: Get latest release tag from source repo
24-
id: get_release
40+
- name: Add Immich upstream remote
2541
run: |
26-
latest_tag=$(curl -s https://api.github.com/repos/immich-app/immich/releases/latest | jq -r .tag_name)
27-
echo "::set-output name=latest_tag::$latest_tag"
28-
shell: bash
42+
git remote add upstream https://github.com/immich-app/immich.git
43+
git fetch upstream --tags
2944
30-
- name: Check if latest release already exists in this branch
31-
id: check_existing
45+
- name: Update `dockerimageML` branch
3246
run: |
33-
if git ls-remote --exit-code --heads origin dockerimageML | grep -q "${{ steps.get_release.outputs.latest_tag }}"; then
34-
echo "exists=true" >> $GITHUB_ENV
35-
else
36-
echo "exists=false" >> $GITHUB_ENV
47+
git branch -f dockerimageML ${{ steps.get_release.outputs.tag }}
48+
git push origin dockerimageML --force
3749
38-
- name: Clone latest release from upstream if new
39-
if: env.exists == 'false'
40-
run: |
41-
git clone --depth 1 --branch "${{ steps.get_release.outputs.latest_tag }}" https://github.com/immich-app/immich temp-clone
42-
rsync -a --delete temp-clone/ ./
43-
rm -rf temp-clone
44-
git config user.name "github-actions"
45-
git config user.email "github-actions@github.com"
46-
git add .
47-
git commit -m "Sync immich release ${{ steps.get_release.outputs.latest_tag }}"
48-
git push origin HEAD:dockerimageML
50+
build:
51+
needs: sync
52+
runs-on: ubuntu-latest
53+
env:
54+
IMAGE_TAG: ${{ needs.sync.outputs.release_tag }}
55+
GHCR_REPO: ghcr.io/${{ github.repository_owner }}
56+
steps:
57+
- name: Checkout `dockerimageML`
58+
uses: actions/checkout@v4
59+
with:
60+
ref: dockerimageML
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@v3
4964

5065
- name: Log in to GHCR
51-
if: env.exists == 'false'
5266
uses: docker/login-action@v3
5367
with:
5468
registry: ghcr.io
5569
username: ${{ github.repository_owner }}
5670
password: ${{ secrets.GHCR_PAT }}
5771

58-
- name: Set up Docker Buildx
59-
if: env.exists == 'false'
60-
uses: docker/setup-buildx-action@v3
61-
62-
- name: Build and push server image
63-
if: env.exists == 'false'
72+
# === Server image ===
73+
- name: Build & push server image
6474
uses: docker/build-push-action@v6
6575
with:
6676
context: .
6777
file: server/Dockerfile
6878
platforms: linux/amd64
6979
push: true
70-
tags: ghcr.io/${{ github.repository_owner }}/immich-server:pr-${{ steps.get_release.outputs.latest_tag }}
80+
tags: |
81+
${{ env.GHCR_REPO }}/immich-server:${{ env.IMAGE_TAG }}
7182
72-
- name: Build and push ML images
73-
if: env.exists == 'false'
83+
# === ML images (CPU + CUDA) ===
84+
- name: Build & push ML images
85+
uses: docker/build-push-action@v6
7486
strategy:
7587
matrix:
76-
include:
77-
- device: cpu
78-
suffix: ""
79-
dockerfile: machine-learning/Dockerfile
80-
- device: cuda
81-
suffix: "-cuda"
82-
dockerfile: machine-learning/Dockerfile
83-
uses: docker/build-push-action@v6
88+
device: [cpu, cuda]
8489
with:
8590
context: machine-learning
86-
file: ${{ matrix.dockerfile }}
91+
file: machine-learning/Dockerfile
8792
platforms: linux/amd64
8893
push: true
8994
build-args: |
9095
DEVICE=${{ matrix.device }}
91-
tags: ghcr.io/${{ github.repository_owner }}/immich-machine-learning:pr-${{ steps.get_release.outputs.latest_tag }}${{ matrix.suffix }}
96+
tags: |
97+
${{ env.GHCR_REPO }}/immich-machine-learning:${{ env.IMAGE_TAG }}${{ matrix.device == 'cuda' && '-cuda' || '' }}

0 commit comments

Comments
 (0)