Merge pull request #138 from adamjsturge/renovate/docker #154
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: Push Multi-Arch Docker Image to Docker Hub | |
on: | |
push: | |
branches: [ "main" ] #, "dev" ] | |
paths: | |
# - ".github/workflows/docker-push.yml" | |
- "Dockerfile" | |
- "docker-compose.yml" | |
- "go.mod" | |
- "go.sum" | |
- "probe.js" | |
- "src/*" | |
- "*.go" | |
env: | |
REGISTRY: docker.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@3b8fed7e4b60203b2aa0ecc6c6d6d91d12c06760 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@70b2cdc6480c1a8b86edf1777157f8f437de2166 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # Remove raw dev tag to add the dev branch back to being seperate | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=branch | |
type=ref,event=tag | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} | |
- name: Create .env file | |
run: touch .env | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: "{{defaultContext}}" | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
file: ./Dockerfile | |
target: prod | |
build-args: | | |
GIT_TAG=${{ github.ref_name }} | |
GIT_COMMIT=${{ github.sha }} | |
GIT_BRANCH=${{ github.ref_name }} | |
# - name: Create and push manifest | |
# run: | | |
# docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ | |
# --amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \ | |
# --amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64 | |
# docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |