Update Docker workflow to log in to GitHub Container Registry and build multi-architecture images with metadata extraction
This commit is contained in:
29
.github/workflows/docker-image-linux.yml
vendored
29
.github/workflows/docker-image-linux.yml
vendored
@@ -22,33 +22,30 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push amd64
|
||||
uses: docker/build-push-action@v6
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
build-args: |
|
||||
ARCH=x86_64
|
||||
images: ${{ env.REGISTRY }}/${{ env.GITHUBUSER }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.GITHUBUSER }}/${{ env.IMAGE_NAME }}:latest
|
||||
type=raw,value=latest
|
||||
type=sha,format=short
|
||||
|
||||
- name: Build and push arm64
|
||||
- name: Build and push both architectures
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
platforms: linux/arm64
|
||||
build-args: |
|
||||
ARCH=aarch64
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.GITHUBUSER }}/${{ env.IMAGE_NAME }}:latest
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Reference in New Issue
Block a user