Skip to content

OwnTone Container

OwnTone Container #579

name: OwnTone Container
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
commit:
description: 'Commit identifier'
required: false
staging:
description: 'Include tag ''staging'''
required: false
type: boolean
version:
description: 'Version identifier'
required: false
latest:
description: 'Include tag ''latest'''
required: false
type: boolean
env:
NAME: ${{ vars.NAME }}
NAMESPACE: ${{ vars.NAMESPACE }}
REPOSITORY_BRANCH: ${{ vars.REPOSITORY_BRANCH }}
REPOSITORY_URL: ${{ vars.REPOSITORY_URL }}
jobs:
preparation:
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.variables.outputs.commit }}
version: ${{ steps.variables.outputs.version }}
steps:
- name: Determine variables
id: variables
run: |
registry=https://hub.docker.com/v2/namespaces/$NAMESPACE/repositories/$NAME/tags
git clone -q -b $REPOSITORY_BRANCH $REPOSITORY_URL source
cd source
commit=$(git log --branches -1 --pretty=format:"%h")
[[ $(curl -LI ${registry}/${commit} -o /dev/null -w '%{http_code}\n' -s) = "200" ]] && commit=${{ github.event.inputs.commit }}
echo "commit=${commit}" >> $GITHUB_OUTPUT
version=$(git describe --tags $(git rev-list --tags --max-count=1))
[[ $(curl -LI ${registry}/${version} -o /dev/null -w '%{http_code}\n' -s) = "200" ]] && version=${{ github.event.inputs.version }}
echo "version=${version}" >> $GITHUB_OUTPUT
staging:
needs: preparation
outputs:
tags: ${{ steps.variables.outputs.tags }}
runs-on: ubuntu-latest
if: needs.preparation.outputs.commit
steps:
- name: Determine variables
id: variables
run: |
prefix=${{ env.NAMESPACE }}/${{ env.NAME }}:
tags=${prefix}${{ needs.preparation.outputs.commit }}
[[ -z "${{ github.event.inputs.commit }}" || "${{ github.event.inputs.staging }}" == "true" ]] && tags+=",${prefix}staging"
echo "tags=${tags}" >> $GITHUB_OUTPUT
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Sign into Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
build-args: |
REPOSITORY_URL=${{ env.REPOSITORY_URL }}
REPOSITORY_BRANCH=${{ env.REPOSITORY_BRANCH }}
REPOSITORY_COMMIT=${{ needs.preparation.outputs.commit }}
context: .
platforms: 'linux/amd64,linux/arm64'
push: true
tags: ${{ steps.variables.outputs.tags }}
production:
needs: preparation
outputs:
tags: ${{ steps.variables.outputs.tags }}
runs-on: ubuntu-latest
if: needs.preparation.outputs.version
steps:
- name: Determine variables
id: variables
run: |
prefix=${{ env.NAMESPACE }}/${{ env.NAME }}:
tags=${prefix}${{ needs.preparation.outputs.version }}
[[ -z "${{ github.event.inputs.version }}" || "${{ github.event.inputs.latest }}" == "true" ]] && tags+=",${prefix}latest"
echo "tags=${tags}" >> $GITHUB_OUTPUT
- name: Check out the repository
uses: actions/checkout@v4
with:
ref: ${{ needs.preparation.outputs.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Sign into Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
build-args: |
REPOSITORY_URL=${{ env.REPOSITORY_URL }}
REPOSITORY_BRANCH=${{ env.REPOSITORY_BRANCH }}
REPOSITORY_VERSION=${{ needs.preparation.outputs.version }}
context: .
platforms: 'linux/amd64,linux/arm64'
push: true
tags: ${{ steps.variables.outputs.tags }}