Merge pull request #1395 from fpiesche/master #1
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: Build Docker image | |
on: | |
# Allow manual runs. | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**/*.md' | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
env: | |
PLATFORMS: linux/arm64/v8,linux/amd64 | |
IMAGE_NAME: "geneweb" | |
PUSH_IMAGE: ${{ github.ref == 'refs/heads/master' }} | |
jobs: | |
build-images: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Generate date stamp | |
run: echo "DATESTAMP=$(date +"%Y.%m.%d")" >> $GITHUB_ENV | |
- name: Generate Docker image metadata | |
id: docker-meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | |
# ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=edge,branch=master | |
type=raw,${{ env.DATESTAMP }} | |
type=ref,event=tag | |
type=sha,prefix=,format=short | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Setup Docker BuildKit | |
uses: docker/setup-buildx-action@v2 | |
# - name: Login to DockerHub | |
# if: ${{ env.PUSH_IMAGE == 'true' }} | |
# uses: docker/login-action@v2 | |
# with: | |
# username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
if: ${{ env.PUSH_IMAGE == 'true' }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ github.token }} | |
- name: Build and push ${{ env.IMAGE_NAME }} Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
target: container | |
context: docker/ | |
file: docker/Dockerfile | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ env.PUSH_IMAGE }} | |
tags: ${{ steps.docker-meta.outputs.tags }} | |
labels: ${{ steps.docker-meta.outputs.labels }} |