Skip to content

add: base, yeth (#19) #21

add: base, yeth (#19)

add: base, yeth (#19) #21

Workflow file for this run

name: Build and push docker image to registry
on:
push:
branches:
- main
workflow_dispatch:
inputs:
git_ref:
description: Git ref
required: true
default: main
workflow_call:
inputs:
git_ref:
description: Git ref
required: true
type: string
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Extract git ref
id: extract_values
run: |
EVENT_GIT_REF=${{ github.event.inputs.git_ref }}
GIT_REF=${EVENT_GIT_REF:-main}
echo "git_ref=${GIT_REF}" >> $GITHUB_OUTPUT
IS_DEFAULT_BRANCH=$([[ ${GIT_REF} == 'main' ]] && echo 'true' || echo 'false')
echo "is_default_branch=${IS_DEFAULT_BRANCH}" >> $GITHUB_OUTPUT
echo "docker_tag=${EVENT_GIT_REF:-latest}" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.extract_values.outputs.git_ref }}
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=${{ steps.extract_values.outputs.is_default_branch }}
type=sha,format=long,enable=${{ steps.extract_values.outputs.is_default_branch }}
type=raw,value=${{ steps.extract_values.outputs.docker_tag }}
# set latest tag for default branch
type=raw,value=latest,enable=${{ steps.extract_values.outputs.is_default_branch }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}