Add multi-arch container image builds (#132)

* Update versions for GH Actions

* Add build arg for Dockerfile

* Add automated tags for container image

* Add multi-arch image builds using QEMU and Buildx

* Add checks to ensure PRs don't publish images

* Auto-indent YAML

* Change web interface version name

* Revert back to `10.8.0` version name
This commit is contained in:
roib20 2023-02-07 10:34:43 +02:00 committed by GitHub
parent 0b62b0209e
commit 84919b65d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 56 deletions

View File

@ -29,7 +29,7 @@ jobs:
run: dotnet build --no-restore run: dotnet build --no-restore
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3.1.1 uses: actions/upload-artifact@v3.1.2
with: with:
name: intro-skipper-${{ github.sha }}.dll name: intro-skipper-${{ github.sha }}.dll
path: ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net6.0/ConfusedPolarBear.Plugin.IntroSkipper.dll path: ConfusedPolarBear.Plugin.IntroSkipper/bin/Debug/net6.0/ConfusedPolarBear.Plugin.IntroSkipper.dll

View File

@ -7,77 +7,116 @@ on:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/jellyfin-intro-skipper
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read
packages: write packages: write
strategy: strategy:
matrix: matrix:
node-version: [18.x] node-version: [18.x]
jellyfin-version: [10.8.9]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Login to GHCR - name: Use Node.js ${{ matrix.node-version }}
uses: docker/login-action@v2.1.0 uses: actions/setup-node@v3
with: with:
registry: ${{ env.REGISTRY }} node-version: ${{ matrix.node-version }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }} - name: Get npm cache directory
uses: actions/setup-node@v3 id: npm-cache-dir
with: run: |
node-version: ${{ matrix.node-version }} echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
- name: Get npm cache directory - name: Configure npm cache
id: npm-cache-dir uses: actions/cache@v3
run: | id: npm-cache
echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Configure npm cache - name: Checkout modified web interface
uses: actions/cache@v3 uses: actions/checkout@v3
id: npm-cache with:
with: repository: ConfusedPolarBear/jellyfin-web
path: ${{ steps.npm-cache-dir.outputs.dir }} ref: intros
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} path: web
restore-keys: |
${{ runner.os }}-node-
- name: Checkout modified web interface - name: Store commit of web interface
uses: actions/checkout@v3 id: web-commit
with: run: |
repository: ConfusedPolarBear/jellyfin-web cd web
ref: intros echo "commit=$(git log -1 --format='%H' | cut -c -10)" >> $GITHUB_OUTPUT
path: web
- name: Store commit of web interface - name: Build and copy web interface
id: web-commit run: |
run: | cd web
cd web npm install
echo "commit=$(git log -1 --format='%H' | cut -c -10)" >> $GITHUB_OUTPUT cp -r dist ../docker/
tar czf dist.tar.gz dist
- name: Build and copy web interface - name: Upload web interface
run: | uses: actions/upload-artifact@v3.1.2
cd web with:
npm install name: jellyfin-web-10.8.0+${{ steps.web-commit.outputs.commit }}.tar.gz
cp -r dist ../docker/ path: web/dist.tar.gz
tar czf dist.tar.gz dist if-no-files-found: error
- name: Upload web interface - name: Set up QEMU
uses: actions/upload-artifact@v3.1.1 uses: docker/setup-qemu-action@v2
with:
name: jellyfin-web-10.8.0+${{ steps.web-commit.outputs.commit }}.tar.gz
path: web/dist.tar.gz
if-no-files-found: error
- name: Publish container - name: Setup Docker buildx
uses: docker/build-push-action@v3.2.0 uses: docker/setup-buildx-action@v2
with:
file: docker/Dockerfile # Login against a Docker registry except on PR
context: docker/ # https://github.com/docker/login-action
push: true - name: Log into ghcr.io registry
tags: ${{ env.REGISTRY}}/confusedpolarbear/jellyfin-intro-skipper:${{ steps.web-commit.outputs.commit }} if: github.event_name != 'pull_request'
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type-raw,value=${{ steps.web-commit.outputs.commit }}
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}},value=${{ matrix.jellyfin-version }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Publish container image
id: build-and-push
uses: docker/build-push-action@v4.0.0
with:
file: docker/Dockerfile
context: docker
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
JELLYFIN_TAG=${{ matrix.jellyfin-version }}
platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
pull: true
no-cache: true
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false

View File

@ -32,7 +32,7 @@ jobs:
run: .github/workflows/package.sh ${{ steps.tag.outputs.tag }} run: .github/workflows/package.sh ${{ steps.tag.outputs.tag }}
- name: Upload plugin archive - name: Upload plugin archive
uses: actions/upload-artifact@v3.1.1 uses: actions/upload-artifact@v3.1.2
with: with:
name: intro-skipper-bundle-${{ steps.tag.outputs.tag }}.zip name: intro-skipper-bundle-${{ steps.tag.outputs.tag }}.zip
path: | path: |

View File

@ -1,3 +1,4 @@
FROM jellyfin/jellyfin:10.8.9 ARG JELLYFIN_TAG=10.8.9
FROM jellyfin/jellyfin:${JELLYFIN_TAG}
COPY dist/ /jellyfin/jellyfin-web/ COPY dist/ /jellyfin/jellyfin-web/