Skip to content

Build and release custom docker image #23

Build and release custom docker image

Build and release custom docker image #23

Workflow file for this run

name: Build and release custom docker image
on:
workflow_dispatch:
inputs:
app_name:
description: 'Application name (must exists in `build` folder)'
required: true
type: string
version:
description: 'Version of application (must exists in `build/<app_name>` folder)'
required: true
type: string
workflow_call:
inputs:
app_name:
description: 'Application name (must exists in `build` folder)'
required: true
type: string
version:
description: 'Version of application (must exists in `build/<app_name>` folder)'
required: true
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: swiftwave-org/app-store/${{ inputs.app_name }}:${{ inputs.version }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set `platforms` variable
run: |
app_name=${{ inputs.app_name }}
version=${{ inputs.version }}
platforms=$(cat "./build/$app_name/$version/.platforms")
echo "platforms=$platforms" >> $GITHUB_ENV
- name: Install cosign
uses: sigstore/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
context: "{{defaultContext}}:build/${{ inputs.app_name }}/${{ inputs.version }}"
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max