Docker Build #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 10 * * *" # Run every day at 10:00 UTC for `nightly` tag | |
push: | |
tags: | |
- "v*.*.*" # Run on version tags only | |
jobs: | |
docker: | |
name: Build - Build and Push Docker Image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64] | |
steps: | |
- name: Docker Meta | |
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=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- 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 | |
if: github.event_name == 'push' || github.event_name == 'schedule' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR | |
if: github.event_name == 'push' || github.event_name == 'schedule' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v6 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: ${{ matrix.platform }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
- name: Clean up Buildx | |
if: always() | |
run: docker buildx rm mybuilder || true |