Skip to content

Build and Push Docker Image #46

Build and Push Docker Image

Build and Push Docker Image #46

name: Build and Push Docker Image
on:
release:
types: [published]
workflow_dispatch:
inputs:
ref_name:
description: "The ref the image should be built for. This is usually the tag of the release."
default: "{{ github.ref_name }}"
required: true
type: string
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Set tag name
run: echo "TAG_NAME=${{ inputs.ref_name || github.ref_name }}" >> $GITHUB_ENV
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: $TAG_NAME
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push builder image
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:$TAG_NAME
- name: Update version in README
run: |
sed 's|image: ghcr.io/rmehner/bits-to-dead-trees:v.*|image: ghcr.io/rmehner/bits-to-dead-trees:$TAG_NAME|' README.md
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "🤖 Update version in README after release"
branch: main