Skip to content

Docker Build

Docker Build #178

Workflow file for this run

name: Docker Build
on:
workflow_dispatch:
schedule:
- cron: "0 10 * * *" # Run every day at 10:00 UTC for nightly tag
push:
tags:
- 'v**'
jobs:
docker:
name: Build and Push Docker Image
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
attestations: write
env:
IMAGE_NAME: ghcr.io/mountaingod2/chaturbate_poller
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Generate Docker Build Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/mountaingod2/chaturbate_poller
docker.io/mountaingod2/chaturbate_poller
tags: |
type=schedule,pattern=nightly
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Export Test Image
uses: docker/build-push-action@v6
with:
load: true
tags: mountaingod2/chaturbate_poller:test
- name: Test Docker Image
run: |
docker run --rm mountaingod2/chaturbate_poller:test --help
- name: Build and Push Docker Image
id: push
uses: docker/build-push-action@v6
with:
push: true
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}-cache,mode=max
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}-cache
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v2
id: attest
with:
subject-name: ghcr.io/mountaingod2/chaturbate_poller
subject-digest: ${{ steps.push.outputs.digest }}