v2.13.0 #784
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: Publish Docker | |
on: | |
workflow_dispatch: ~ | |
push: | |
branches: [master, beta, nightly] | |
tags: [v*] | |
jobs: | |
build-docker: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Prepare | |
id: prepare | |
run: | | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
elif [[ $GITHUB_REF == refs/heads/master ]]; then | |
echo "tag=latest" >> $GITHUB_OUTPUT | |
else | |
echo "tag=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
fi | |
if [[ $GITHUB_REF == refs/tags/*-beta ]]; then | |
echo "branch=beta" >> $GITHUB_OUTPUT | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
echo "branch=master" >> $GITHUB_OUTPUT | |
else | |
echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
fi | |
echo "commit=${GITHUB_SHA}" >> $GITHUB_OUTPUT | |
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
echo "docker_platforms=linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6" >> $GITHUB_OUTPUT | |
echo "docker_image=${{ secrets.DOCKER_REPO }}/tautulli" >> $GITHUB_OUTPUT | |
- name: Set Up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
version: latest | |
- name: Cache Docker Layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: success() | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
if: success() | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Docker Build and Push | |
uses: docker/build-push-action@v4 | |
if: success() | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
platforms: ${{ steps.prepare.outputs.docker_platforms }} | |
build-args: | | |
TAG=${{ steps.prepare.outputs.tag }} | |
BRANCH=${{ steps.prepare.outputs.branch }} | |
COMMIT=${{ steps.prepare.outputs.commit }} | |
BUILD_DATE=${{ steps.prepare.outputs.build_date }} | |
tags: | | |
${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.tag }} | |
ghcr.io/${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.tag }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
discord: | |
name: Discord Notification | |
needs: build-docker | |
if: always() && !contains(github.event.head_commit.message, '[skip ci]') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Build Job Status | |
uses: technote-space/workflow-conclusion-action@v3 | |
- name: Combine Job Status | |
id: status | |
run: | | |
failures=(neutral, skipped, timed_out, action_required) | |
if [[ ${array[@]} =~ $WORKFLOW_CONCLUSION ]]; then | |
echo "status=failure" >> $GITHUB_OUTPUT | |
else | |
echo "status=$WORKFLOW_CONCLUSION" >> $GITHUB_OUTPUT | |
fi | |
- name: Post Status to Discord | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ steps.status.outputs.status }} | |
title: ${{ github.workflow }} | |
nofail: true |