Skip to content

Commit

Permalink
refactor: Update Docker build workflow for multi-platform support and…
Browse files Browse the repository at this point in the history
… cleanup

- Added permissions for read access to contents and write access to packages
- Updated strategy matrix to include linux/amd64 and linux/arm64 platforms
- Updated Docker Meta step name to "Docker Meta"
- Added driver-opts for network=host in Set up Docker Buildx step
- Updated conditions for Login to Docker Hub and Login to GHCR steps to only run on push and schedule events
- Added platforms parameter in Build and Push Docker Image step to build for multiple platforms
- Added Clean up Buildx step to remove the buildx builder
  • Loading branch information
MountainGod2 committed Nov 2, 2024
1 parent 432606e commit f6f70c5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
platform: [linux/amd64, linux/arm64]

steps:
- name: Docker meta
- 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
type=schedule,pattern=nightly
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
Expand All @@ -33,25 +40,32 @@ jobs:

- 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 != 'pull_request'
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 != 'pull_request'
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
- 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 }}

- name: Clean up Buildx
if: always()
run: docker buildx rm mybuilder || true

0 comments on commit f6f70c5

Please sign in to comment.