This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
Update Dockerfile #274
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 | |
on: | |
release: | |
types: [published] | |
push: | |
branches: | |
- "main" | |
- "*" | |
pull_request: | |
branches: ["**"] | |
env: | |
# Hostname of your registry | |
REGISTRY: docker.io | |
# Image repository, without hostname and tag | |
IMAGE_NAME: archblood/humhub-docker | |
SHA: ${{ github.sha }} | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Docker buildx | |
if: matrix.os == 'ubuntu-latest' | |
uses: docker/setup-buildx-action@v3 | |
- name: Authenticate to registry | |
if: matrix.os == 'ubuntu-latest' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract Docker metadata | |
if: matrix.os == 'ubuntu-latest' | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.source=${{ github.repositoryUrl }} | |
org.opencontainers.image.revision=${{ env.SHA }} | |
tags: | | |
type=ref,event=branch,pattern=main | |
type=ref,event=branch,pattern=.* | |
- name: Set up release tag | |
if: matrix.os == 'ubuntu-latest' && github.event_name == 'release' | |
id: vars | |
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
if: matrix.os == 'ubuntu-latest' | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: src/Dockerfile | |
sbom: ${{ github.event_name != 'pull_request' }} | |
provenance: ${{ github.event_name != 'pull_request' }} | |
push: ${{ github.event_name != 'pull_request' }} | |
load: ${{ github.event_name == 'pull_request' }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_TAG || 'latest' }} | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Windows step | |
if: matrix.os == 'windows-latest' | |
run: echo "No steps for Windows in this job." | |
- name: macOS step | |
if: matrix.os == 'macos-latest' | |
run: echo "No steps for macOS in this job." |