1
0
mirror of https://github.com/gilbN/theme.park.git synced 2024-11-20 01:52:32 +01:00
theme.park/.github/workflows/docker-build.yml
2022-04-02 19:47:25 +02:00

118 lines
4.1 KiB
YAML

name: docker build
on:
release:
types:
- released
workflow_dispatch:
inputs:
branch:
description: 'Select branch'
required: true
type: choice
options:
- master
- develop
- testing
tag:
description: 'Add a tag'
push:
branches:
- develop
- testing
paths-ignore:
- '.github/**'
jobs:
build-and-push-it-to-the-limit:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [armhf, aarch64, amd64]
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Prepare
id: prep
run: |
ARCHITECTURE=${{ matrix.architecture }}
echo ::set-output name=VERSION::${{ github.event.release.tag_name }}
echo ::set-output name=platform::${ARCHITECTURE}
- name: Set current date as env variable
id: date_time
run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S')
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
id: metadata
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/gilbn/theme.park
gilbn/theme.park
tags: |
type=ref,event=branch
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DH_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build&push master
if: ${{ github.event.release.target_commitish == 'master' }}
uses: docker/build-push-action@v2
with:
file: ./Dockerfile.${{ matrix.architecture }}
platforms: ${{ matrix.architecture }
push: ${{ github.event_name != 'pull_request' }}
tags: latest, ${{ steps.prep.outputs.VERSION }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: TP_RELEASE=${{ steps.prep.outputs.VERSION }},BUILD_DATE=${{ steps.date_time.outputs.NOW }}
- name: manual build&push master
if: ${{ github.event.inputs.branch == 'master' }}
uses: docker/build-push-action@v2
with:
file: ./Dockerfile.${{ matrix.architecture }}
platforms: ${{ matrix.architecture }
push: ${{ github.event_name != 'pull_request' }}
tags: latest, ${{ github.event.inputs.tag }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: TP_RELEASE=${{ steps.prep.outputs.VERSION }},BUILD_DATE=${{ steps.date_time.outputs.NOW }}
- name: build&push develop
if: ${{ github.ref == 'refs/heads/develop' || github.event.inputs.branch == 'develop' }}
uses: docker/build-push-action@v2
with:
file: ./Dockerfile.${{ matrix.architecture }}
platforms: ${{ matrix.architecture }
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: TP_RELEASE=${{ steps.prep.outputs.VERSION }},BUILD_DATE=${{ steps.date_time.outputs.NOW }}
- name: build&push testing
if: ${{ github.ref == 'refs/heads/testing' || github.event.inputs.branch == 'testing' }}
uses: docker/build-push-action@v2
with:
file: ./Dockerfile.${{ matrix.architecture }}
platforms: ${{ matrix.architecture }
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: TP_RELEASE=${{ steps.prep.outputs.VERSION }},BUILD_DATE=${{ steps.date_time.outputs.NOW }}, PLATFORM=${{ steps.prep.outputs.platform }}