CI: make building container image optional; tag it with the git version

This commit is contained in:
phil 2024-11-02 18:41:14 +01:00
parent 09f487ea2b
commit 9a0406d9e8

View file

@ -1,5 +1,12 @@
on:
push:
workflow_dispatch:
inputs:
build:
description: "Build container"
required: false
default: false
type: boolean
jobs:
build:
@ -24,20 +31,28 @@ jobs:
- name: Build package (transpile ts => js)
run: ng build
- name: Get the version from git
id: version
if: ${{ inputs.build }}
run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT
- name: Build container
if: ${{ inputs.build }}
uses: actions/buildah-build@v1
with:
image: treetrail-frontend
#tags: foo # v1 ${{ github.sha }}
tags: ${{ steps.version.outputs.version }}
containerfiles: |
./Containerfile
- name: Workaround for bug of podman-login
if: ${{ inputs.build }}
run: |
mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to container registry (with another workaround)
if: ${{ inputs.build }}
uses: actions/podman-login@v1
with:
registry: ${{ vars.REGISTRY }}
@ -46,7 +61,8 @@ jobs:
auth_file_path: /tmp/auth.json
- uses: actions/push-to-registry@v2
if: ${{ inputs.build }}
with:
registry: "docker://${{ vars.REGISTRY }}"
image: treetrail-frontend
tags: latest
tags: ${{ steps.version.outputs.version }}