CI: build container when the version is a clean tag
This commit is contained in:
parent
cc4584ae97
commit
b523ead55f
1 changed files with 29 additions and 3 deletions
|
@ -1,25 +1,49 @@
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
build:
|
||||||
|
description: "Build container"
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: container
|
runs-on: container
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
- name: Git unshallow - get all history from Git to get the tag for the computation of the version
|
fetch-depth: 0
|
||||||
run: git pull --unshallow
|
|
||||||
|
|
||||||
- name: Get the version from git
|
- name: Get the version from git
|
||||||
id: version
|
id: version
|
||||||
run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT
|
run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Check if the container should be built
|
||||||
|
id: builder
|
||||||
|
env:
|
||||||
|
RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }}
|
||||||
|
run: |
|
||||||
|
echo "run=$RUN" >> $GITHUB_OUTPUT
|
||||||
|
echo "Run build: $RUN"
|
||||||
|
|
||||||
|
- name: Info - version and if the image container should be built
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.version.outputs.version }}
|
||||||
|
RUN: ${{ steps.builder.outputs.run }}
|
||||||
|
FORCE: ${{ toJSON(inputs.build) }}
|
||||||
|
run: |
|
||||||
|
echo "Version $VERSION, force (manual input): $FORCE, run the build: $RUN"
|
||||||
|
|
||||||
- name: Workaround for bug of podman-login
|
- name: Workaround for bug of podman-login
|
||||||
|
if: fromJSON(steps.builder.outputs.run)
|
||||||
run: |
|
run: |
|
||||||
mkdir -p $HOME/.docker
|
mkdir -p $HOME/.docker
|
||||||
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
|
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
|
||||||
|
|
||||||
- name: Log in to the container registry (with another workaround)
|
- name: Log in to the container registry (with another workaround)
|
||||||
|
if: fromJSON(steps.builder.outputs.run)
|
||||||
uses: actions/podman-login@v1
|
uses: actions/podman-login@v1
|
||||||
with:
|
with:
|
||||||
registry: ${{ vars.REGISTRY }}
|
registry: ${{ vars.REGISTRY }}
|
||||||
|
@ -28,6 +52,7 @@ jobs:
|
||||||
auth_file_path: /tmp/auth.json
|
auth_file_path: /tmp/auth.json
|
||||||
|
|
||||||
- name: Build the container image
|
- name: Build the container image
|
||||||
|
if: fromJSON(steps.builder.outputs.run)
|
||||||
uses: actions/buildah-build@v1
|
uses: actions/buildah-build@v1
|
||||||
with:
|
with:
|
||||||
image: treetrail-backend
|
image: treetrail-backend
|
||||||
|
@ -38,6 +63,7 @@ jobs:
|
||||||
./Containerfile
|
./Containerfile
|
||||||
|
|
||||||
- name: Push the image to the registry
|
- name: Push the image to the registry
|
||||||
|
if: fromJSON(steps.builder.outputs.run)
|
||||||
uses: actions/push-to-registry@v2
|
uses: actions/push-to-registry@v2
|
||||||
with:
|
with:
|
||||||
registry: "docker://${{ vars.REGISTRY }}"
|
registry: "docker://${{ vars.REGISTRY }}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue