Files
immich-sync/.gitea/workflows/container.yml
T
feedc0de dea9ed7ab0
Publish and promote container image / Build and push (push) Successful in 36s
Publish and promote container image / Promote image in GitOps (push) Successful in 17s
Deploy immich-sync through Argo CD
2026-10-18 13:02:46 +02:00

98 lines
2.9 KiB
YAML

name: Publish and promote container image
on:
push:
env:
IMAGE: registry.brunner.ninja/feedc0de/immich-sync
GITOPS_REPOSITORY: feedc0de/homelab-gitops
jobs:
publish:
name: Build and push
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Log in to Quay
uses: docker/login-action@v3
with:
registry: registry.brunner.ninja
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build image
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
docker build \
--load \
--label "org.opencontainers.image.revision=${COMMIT_SHA}" \
--label "org.opencontainers.image.source=https://code.brunner.ninja/feedc0de/immich-sync" \
--tag "${IMAGE}:${COMMIT_SHA}" \
.
- name: Push commit tag
env:
COMMIT_SHA: ${{ gitea.sha }}
run: docker push "${IMAGE}:${COMMIT_SHA}"
- name: Push latest tag
if: gitea.ref == 'refs/heads/main'
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
docker tag "${IMAGE}:${COMMIT_SHA}" "${IMAGE}:latest"
docker push "${IMAGE}:latest"
promote:
name: Promote image in GitOps
if: gitea.ref == 'refs/heads/main'
needs: publish
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Check that this is still the current main commit
id: current-main
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
git fetch --no-tags origin main
if [ "$(git rev-parse FETCH_HEAD)" = "${COMMIT_SHA}" ]; then
echo "promote=true" >> "${GITEA_OUTPUT}"
else
echo "This build is no longer the current main commit; skipping promotion"
echo "promote=false" >> "${GITEA_OUTPUT}"
fi
- name: Check out GitOps repository
if: steps.current-main.outputs.promote == 'true'
uses: actions/checkout@v4
with:
repository: ${{ env.GITOPS_REPOSITORY }}
ref: main
token: ${{ secrets.GITOPS_TOKEN }}
path: homelab-gitops
- name: Commit image promotion
if: steps.current-main.outputs.promote == 'true'
working-directory: homelab-gitops
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
./scripts/update-immich-sync-image.sh "${COMMIT_SHA}"
git config user.name "immich-sync CI"
git config user.email "immich-sync-ci@brunner.ninja"
git add apps/immich-sync/kustomization.yaml
if git diff --cached --quiet; then
echo "GitOps already selects ${COMMIT_SHA}"
exit 0
fi
git commit -m "Deploy immich-sync ${COMMIT_SHA}"
git push origin HEAD:main