Skip to content

Commit

Permalink
Update docker-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
docjyJ authored Jun 12, 2024
1 parent b2df899 commit 257e3f1
Showing 1 changed file with 49 additions and 22 deletions.
71 changes: 49 additions & 22 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,69 @@
name: Docker Build and Publish
name: Build and Publish Docker image in GitHub Container Registry

on:
workflow_dispatch:
inputs:
tagName:
description: "Tag name"
required: true
default: 'v2'
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'

jobs:
push_to_registry:
docker:
runs-on: ubuntu-latest

name: Build docker image and push to dockerhub
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Check out the repo
- name: Checkout repository
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: Login to DockerHub
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=develop
type=raw,value=beta
type=ref,event=pr
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern=v{{major}}
type=sha
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build container image
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
context: './'
no-cache: true
file: 'Dockerfile'
tags: marcoambrosini/aio-stalwart:${{ github.event.inputs.tagName }}
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ghcr.io/${{ github.repository }}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: ${{ github.event_name != 'pull_request' }}

0 comments on commit 257e3f1

Please sign in to comment.