Build Image #4
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 Image | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: version string in the form e.g. 20.16.5_xxx | |
type: text | |
required: true | |
buildnr: | |
type: text | |
required: false | |
debug: | |
type: boolean | |
required: false | |
default: false | |
push: | |
paths: | |
- 'CHANGELOG.md' | |
- 'CHANGELOG-MWE_MODS.md' | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Date | |
id: date | |
run: echo "::set-output name=date::$(date +%s)" | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Create Image Tags and Labels | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
hobbit00378/izpbx-asterisk | |
ghcr.io/hobbit378/izpbx-asterisk | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
# set latest tag for default branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
# set latest suffix in connection with branch | |
type=ref,event=branch,suffix=-latest | |
# set version from git tag | |
type=semver,pattern={{version}} | |
# set latest suffix in connection with version | |
type=semver,pattern={{major}}.{{minor}},suffix=-latest | |
# set tag from input | |
type=raw,value=${{ inputs.version }} | |
labels: | | |
org.opencontainers.image.title=izpbx-mwe | |
org.opencontainers.image.source=https://github.com/hobbit378/docker-izpbx | |
- name: Build and Push Image | |
uses: docker/build-push-action@v4 | |
with: | |
platforms: linux/amd64 | |
context: ./izpbx-asterisk/ | |
build-args: APP_VER=${{ inputs.version }} APP_BUILD_DATE=${{ steps.date.outputs.date }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |