Skip to content

Build and push docker image #269

Build and push docker image

Build and push docker image #269

name: Build and push docker image
on:
schedule:
- cron: "0 3 * * *"
push:
branches:
- main
env:
IMAGE_NAME: snapcast
NAMESPACE: sweisgerber
jobs:
docker:
runs-on: ubuntu-latest
environment: main
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to the Docker Hub registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the ghcr Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- 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=schedule
# type=ref,event=branch
type=ref,event=tag
# type=ref,event=pr
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}