Bumps [docker/login-action](https://github.com/docker/login-action) from 4.5.1 to 4.6.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v4.5.1...v4.6.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-version: 4.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
108 lines
5.1 KiB
YAML
108 lines
5.1 KiB
YAML
# Builds and pushes a docker image in the following scenarios:
|
|
# When a commit is made to 'master' or 'development'.
|
|
# Tag pattern
|
|
# 'master' branch - rolling, rolling-classic (for commits)
|
|
# - [tag], [tag]-classic, latest, classic (for tags)
|
|
# 'development' branch - development, development-classic (for all pushes including tags)
|
|
# Builds but does not push a docker image for PRs.
|
|
name: Build and conditionally push docker image
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- master
|
|
- development
|
|
tags:
|
|
- "*"
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
jobs:
|
|
docker-vars:
|
|
uses: ./.github/workflows/docker-vars.yaml
|
|
build-docker-image-and-publish:
|
|
name: Build and conditionally push docker image
|
|
needs:
|
|
- docker-vars
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- name: classic
|
|
dockerfile: ./docker/classic/Dockerfile
|
|
build_args: |
|
|
SHAIRPORT_SYNC_BRANCH=.
|
|
- name: main
|
|
dockerfile: ./docker/Dockerfile
|
|
build_args: |
|
|
SHAIRPORT_SYNC_BRANCH=.
|
|
NQPTP_BRANCH=${{ needs.docker-vars.outputs.nqptp_branch }}
|
|
steps:
|
|
- name: Checkout shairport sync repo
|
|
uses: actions/checkout@v7.0.1
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Determine which branch the tag belongs to
|
|
id: determine_branch
|
|
if: github.ref_type == 'tag'
|
|
run: |
|
|
# Check which branch contains this tag
|
|
if git branch -r --contains ${{ github.sha }} | grep -q 'origin/master'; then
|
|
echo "branch=master" >> $GITHUB_OUTPUT
|
|
echo "Tag ${{ github.ref_name }} is on master branch"
|
|
elif git branch -r --contains ${{ github.sha }} | grep -q 'origin/development'; then
|
|
echo "branch=development" >> $GITHUB_OUTPUT
|
|
echo "Tag ${{ github.ref_name }} is on development branch"
|
|
else
|
|
echo "branch=unknown" >> $GITHUB_OUTPUT
|
|
echo "Warning: Tag ${{ github.ref_name }} is not on master or development branch"
|
|
fi
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v4.6.0
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
|
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
|
if: needs.docker-vars.outputs.push_docker_image == 'true'
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v4.2.0
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4.2.0
|
|
|
|
- name: Build and push ${{ matrix.name }}
|
|
uses: docker/build-push-action@v7.3.0
|
|
env:
|
|
registry_and_name: ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}
|
|
with:
|
|
context: ./
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: ${{ needs.docker-vars.outputs.docker_platforms }}
|
|
push: ${{ needs.docker-vars.outputs.push_docker_image == 'true' }}
|
|
# Assign tags based on branch or tag type for clarity
|
|
tags: |
|
|
${{ github.ref_type == 'branch' && github.ref_name == 'development' && matrix.name == 'main'
|
|
&& format('{0}:development', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'branch' && github.ref_name == 'development' && matrix.name == 'classic'
|
|
&& format('{0}:development-classic', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'development' && matrix.name == 'main'
|
|
&& format('{0}:development', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'development' && matrix.name == 'classic'
|
|
&& format('{0}:development-classic', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'branch' && github.ref_name == 'master' && matrix.name == 'main'
|
|
&& format('{0}:rolling', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'branch' && github.ref_name == 'master' && matrix.name == 'classic'
|
|
&& format('{0}:rolling-classic', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'main'
|
|
&& format('{0}:{1}', env.registry_and_name, github.ref_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'classic'
|
|
&& format('{0}:{1}-classic', env.registry_and_name, github.ref_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'main'
|
|
&& format('{0}:latest', env.registry_and_name) || '' }}
|
|
${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'classic'
|
|
&& format('{0}:classic', env.registry_and_name) || '' }}
|
|
build-args: |
|
|
${{ matrix.build_args }}
|