116 lines
3.9 KiB
YAML
116 lines
3.9 KiB
YAML
name: Publish Docker
|
|
|
|
on:
|
|
push:
|
|
branches: [master, beta, nightly]
|
|
tags: [v*]
|
|
pull_request: ~
|
|
|
|
jobs:
|
|
build-docker:
|
|
name: Build Docker Image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Prepare
|
|
id: prepare
|
|
run: |
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
|
|
elif [[ $GITHUB_REF == refs/heads/master ]]; then
|
|
echo ::set-output name=tag::latest
|
|
else
|
|
echo ::set-output name=tag::${GITHUB_REF#refs/heads/}
|
|
fi
|
|
if [[ $GITHUB_REF == refs/tags/*-beta ]]; then
|
|
echo ::set-output name=branch::beta
|
|
elif [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
echo ::set-output name=branch::master
|
|
else
|
|
echo ::set-output name=branch::${GITHUB_REF#refs/heads/}
|
|
fi
|
|
echo ::set-output name=commit::${GITHUB_SHA}
|
|
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
echo ::set-output name=docker_platforms::linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6
|
|
echo ::set-output name=docker_image::${{ secrets.DOCKER_REPO }}/tautulli
|
|
|
|
- name: Set Up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
id: buildx
|
|
with:
|
|
version: latest
|
|
|
|
- name: Cache Docker Layers
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
if: success() && github.event_name != 'pull_request'
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v1
|
|
if: success() && github.event_name != 'pull_request'
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.GHCR_TOKEN }}
|
|
|
|
- name: Docker Build and Push
|
|
uses: docker/build-push-action@v2
|
|
if: success()
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
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() && github.event_name != 'pull_request'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Get Build Job Status
|
|
uses: technote-space/workflow-conclusion-action@v1
|
|
|
|
- name: Combine Job Status
|
|
id: status
|
|
run: |
|
|
failures=(neutral, skipped, timed_out, action_required)
|
|
if [[ ${array[@]} =~ $WORKFLOW_CONCLUSION ]]; then
|
|
echo ::set-output name=status::failure
|
|
else
|
|
echo ::set-output name=status::$WORKFLOW_CONCLUSION
|
|
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
|