forked from chrisbenincasa/tunarr
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.19 KB
/
edge-build.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
name: Push Docker Edge
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *' # Hourly
jobs:
build_and_push:
runs-on: ubuntu-latest
strategy:
matrix:
builds:
- base_tag: '7.0'
tag: edge
- base_tag: 7.0-nvidia
tag: edge-nvidia
- base_tag: 7.0-vaapi
tag: edge-vaapi
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache@v4 # Cache previous HEAD SHA
with:
path: previous_head_sha
key: ${{ runner.os }}-edge-build-${{ github.sha }}
restore-keys: | # Check for previous SHA in cache
${{ runner.os }}-edge-build-
- name: Check for HEAD commit changes
run: |
git fetch origin main
HEAD_SHA=$(git rev-parse HEAD)
if [[ -z "$PREVIOUS_HEAD_SHA" ]]; then
echo "No previous HEAD SHA found (first run). Building image."
elif [[ "$HEAD_SHA" != "$PREVIOUS_HEAD_SHA" ]]; then
echo "Head commit has changed. Building and pushing image."
else
echo "Head commit hasn't changed. Skipping build."
exit 0 # Exit without pushing the image
fi
echo "PREVIOUS_HEAD_SHA=$HEAD_SHA" >> previous_head_sha # Save current SHA for next run
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: base_image_tag=${{ matrix.builds.base_tag }}
target: full-stack
tags: |
chrisbenincasa/tunarr:${{ matrix.builds.tag }}
ghcr.io/chrisbenincasa/tunarr:${{ matrix.builds.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max