Skip to content

refactor(github): change workflow #2

refactor(github): change workflow

refactor(github): change workflow #2

Workflow file for this run

name: Build & Push to container registry
on:
release:
types: [created]
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/[email protected]
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tag name
id: tags
if: ${{ github.event_name == 'release' }}
run: echo "name=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Add dev suffix
id: dev-suffix
if: ${{ github.event_name != 'release' }}
run: echo "name=-dev" >> $GITHUB_OUTPUT
- name: Generate Docker image metadata
uses: docker/metadata-action@v5
id: img_meta
with:
flavor: |
latest=auto
suffix=${{ steps.dev-suffix.outputs.name }}
images: ghcr.io/${{ github.repository }}
tags: |
${{ steps.tags.outputs.name }}
latest
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./
tags: ${{ steps.img_meta.outputs.tags }}
labels: ${{ steps.img_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
secrets: |
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max