Skip to content

.github/workflows/templates-build-push-image.yml #28

.github/workflows/templates-build-push-image.yml

.github/workflows/templates-build-push-image.yml #28

name: Build and Push (Linux)
on:
workflow_dispatch:
inputs:
image_name:
required: true
type: string
version:
required: true
type: string
project_name:
required: true
type: string
jobs:
linux:
name: Build & Push (Linux)
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: "Determine preview artifact version"
run: |
echo "artifact_full_version=${{ inputs.version }}-${{ github.sha }}" >> $GITHUB_ENV
- name: "Determine full container image uri (commit)"
run: |
echo "image_commit_uri=${{ inputs.image_name }}:$artifact_full_version" >> $GITHUB_ENV
- name: "Determine full container image uri (latest)"
run: |
echo "image_latest_uri=${{ inputs.image_name }}:${{ inputs.version }}" >> $GITHUB_ENV
- name: Determine container image metadata
uses: docker/[email protected]
with:
images: ${{ inputs.image_name }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: hkfgo
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push preview image
uses: docker/[email protected]
with:
build-args: VERSION="${{ env.artifact_full_version }}"
context: ./src/
file: ./src/${{ inputs.project_name }}/Dockerfile.linux
tags: ghcr.io/hkfgo/${{ env.image_commit_uri }},ghcr.io/hkfgo/${{ env.image_latest_uri }}
push: true