audiobookshelf/.github/workflows/docker-build.yml

83 lines
2.1 KiB
YAML
Raw Normal View History

2022-04-29 01:40:29 +02:00
---
name: Build and Push Docker Image
on:
# Allows you to run workflow manually from Actions tab
workflow_dispatch:
inputs:
tags:
description: 'Docker Tag'
required: true
default: 'latest'
2022-04-29 01:40:29 +02:00
push:
branches: [main,master]
2022-04-29 01:40:29 +02:00
tags:
- 'v*.*.*'
# Only build when files in these directories have been changed
paths:
- client/**
- server/**
2022-04-29 16:48:00 +02:00
- index.js
- package.json
2022-04-29 01:40:29 +02:00
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-20.04
steps:
- name: Check out
uses: actions/checkout@v3
2022-04-29 01:40:29 +02:00
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
2022-04-29 01:40:29 +02:00
with:
2022-04-29 20:01:12 +02:00
images: advplyr/audiobookshelf,ghcr.io/${{ github.repository_owner }}/audiobookshelf
2022-04-29 01:40:29 +02:00
tags: |
type=edge,branch=master
type=semver,pattern={{version}}
2022-04-29 01:40:29 +02:00
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
2022-04-29 01:40:29 +02:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
2022-04-29 16:48:00 +02:00
- name: Cache Docker layers
uses: actions/cache@v3
2022-04-29 16:48:00 +02:00
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
2022-04-29 01:40:29 +02:00
- name: Login to Dockerhub
uses: docker/login-action@v2
2022-04-29 01:40:29 +02:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
2022-04-29 01:40:29 +02:00
- name: Login to ghcr
uses: docker/login-action@v2
2022-04-29 01:40:29 +02:00
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v3
2022-04-29 01:40:29 +02:00
with:
tags: ${{ github.event.inputs.tags || steps.meta.outputs.tags }}
2022-04-29 01:40:29 +02:00
context: .
2024-01-20 23:39:43 +01:00
platforms: linux/amd64,linux/arm64
2022-04-29 01:40:29 +02:00
push: true
2022-04-29 16:48:00 +02:00
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
2022-04-29 16:48:00 +02:00
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache