Skip to content

Using env vars with proper prefix env. #298

Using env vars with proper prefix env.

Using env vars with proper prefix env. #298

name: Build and push docker image
on:
schedule:
- cron: "0 3 * * *"
push:
branches:
- main
env:
IMAGE_NAME: snapcast
NAMESPACE: sweisgerber
SNAPCAST_VERSION: 0.31.0-r0
LIBRESPOT_VERSION: 0.6.0-r0
jobs:
docker:
runs-on: ubuntu-latest
environment: main
steps:
# CHECKOUT
- name: Checkout
uses: actions/checkout@v3
# QEMU Setup
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# BUILDX Setup
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# DockerHub Login
- name: Login to the Docker Hub registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GHCR Docker Login
- name: Log in to the ghcr Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Metadata
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: |
${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=v${SNAPCAST_VERSION},enable={{is_default_branch}}
type=schedule
# type=ref,event=branch
type=ref,event=tag
# type=ref,event=pr
# Build & Push
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
SNAPCAST_VERSION=${{ env.SNAPCAST_VERSION }}
LIBRESPOT_VERSION=${{ env.LIBRESPOT_VERSION }}
VERSION=snapcast-${{ env.SNAPCAST_VERSION }}-librespot-${{ env.LIBRESPOT_VERSION }}