Push Docker Edge #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |