Build and Push Docker Image #49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | |
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: ${{ env.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 }}:${{ env.TAG_NAME }} | |
- name: Update version in README | |
run: | | |
sed -i 's|image: ghcr.io/rmehner/bits-to-dead-trees:v.*|image: ghcr.io/rmehner/bits-to-dead-trees:${{ env.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 |