2024-10-25 13:51:15 +02:00
|
|
|
on:
|
|
|
|
push:
|
2024-11-02 18:41:14 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
build:
|
|
|
|
description: "Build container"
|
2024-11-09 02:32:42 +01:00
|
|
|
required: true
|
2024-11-02 18:41:14 +01:00
|
|
|
default: false
|
|
|
|
type: boolean
|
2024-10-25 13:51:15 +02:00
|
|
|
|
2024-10-19 12:22:57 +02:00
|
|
|
jobs:
|
2024-10-19 12:29:53 +02:00
|
|
|
build:
|
2024-10-19 12:22:57 +02:00
|
|
|
runs-on: container
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-11-03 15:55:03 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2024-10-23 01:43:52 +02:00
|
|
|
|
2024-11-03 16:19:52 +01:00
|
|
|
- name: Get the version from git
|
|
|
|
id: version
|
|
|
|
run: echo "version=$(git describe --dirty --tags)" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Check if the container should be built
|
|
|
|
id: builder
|
2024-11-03 18:50:39 +01:00
|
|
|
env:
|
2024-11-03 18:54:42 +01:00
|
|
|
RUN: ${{ toJSON(inputs.build || !contains(steps.version.outputs.version, '-')) }}
|
2024-11-03 18:50:39 +01:00
|
|
|
run: |
|
|
|
|
echo "run=$RUN" >> $GITHUB_OUTPUT
|
|
|
|
echo "Run build: $RUN"
|
2024-11-03 16:19:52 +01:00
|
|
|
|
2024-11-03 18:58:37 +01:00
|
|
|
- name: Info - version and if the image container should be built
|
2024-11-03 18:44:21 +01:00
|
|
|
env:
|
|
|
|
VERSION: ${{ steps.version.outputs.version }}
|
2024-11-03 18:53:59 +01:00
|
|
|
RUN: ${{ steps.builder.outputs.run }}
|
2024-11-03 18:59:22 +01:00
|
|
|
FORCE: ${{ toJSON(inputs.build) }}
|
2024-11-03 16:27:07 +01:00
|
|
|
run: |
|
2024-11-03 18:58:37 +01:00
|
|
|
echo "Version $VERSION, force (manual input): $FORCE, run the build: $RUN"
|
2024-11-03 16:19:52 +01:00
|
|
|
|
2024-10-19 12:22:57 +02:00
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
name: Install pnpm
|
|
|
|
with:
|
|
|
|
run_install: false
|
|
|
|
|
|
|
|
- name: Install Node.js
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: 20
|
2024-11-01 06:34:41 +01:00
|
|
|
cache: "pnpm"
|
2024-10-19 12:22:57 +02:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm install
|
|
|
|
|
2024-11-09 02:32:42 +01:00
|
|
|
- name: Update version.json from git describe
|
|
|
|
run: pnpm run version
|
|
|
|
|
2024-10-23 01:43:52 +02:00
|
|
|
- name: Build package (transpile ts => js)
|
|
|
|
run: ng build
|
|
|
|
|
2024-10-25 05:21:55 +02:00
|
|
|
- name: Build container
|
2024-11-03 18:31:25 +01:00
|
|
|
if: fromJSON(steps.builder.outputs.run)
|
2024-10-25 13:55:33 +02:00
|
|
|
uses: actions/buildah-build@v1
|
2024-10-23 01:43:52 +02:00
|
|
|
with:
|
2024-10-25 05:21:55 +02:00
|
|
|
image: treetrail-frontend
|
2024-11-03 02:50:12 +01:00
|
|
|
oci: true
|
|
|
|
labels: treetrail-frontend
|
2024-11-02 18:41:14 +01:00
|
|
|
tags: ${{ steps.version.outputs.version }}
|
2024-10-25 05:21:55 +02:00
|
|
|
containerfiles: |
|
|
|
|
./Containerfile
|
2024-11-09 02:32:42 +01:00
|
|
|
build-args: |
|
|
|
|
APP_VERSION=${{ steps.version.outputs.version }}
|
2024-10-25 13:51:15 +02:00
|
|
|
|
2024-11-01 06:34:41 +01:00
|
|
|
- name: Workaround for bug of podman-login
|
2024-11-03 18:31:25 +01:00
|
|
|
if: fromJSON(steps.builder.outputs.run)
|
2024-11-01 06:34:41 +01:00
|
|
|
run: |
|
2024-11-01 13:57:55 +01:00
|
|
|
mkdir -p $HOME/.docker
|
2024-11-01 06:34:41 +01:00
|
|
|
echo "{ \"auths\": {} }" > $HOME/.docker/config.json
|
|
|
|
|
|
|
|
- name: Log in to container registry (with another workaround)
|
2024-11-03 18:31:25 +01:00
|
|
|
if: fromJSON(steps.builder.outputs.run)
|
2024-11-01 06:34:41 +01:00
|
|
|
uses: actions/podman-login@v1
|
|
|
|
with:
|
|
|
|
registry: ${{ vars.REGISTRY }}
|
|
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
auth_file_path: /tmp/auth.json
|
|
|
|
|
2024-11-09 02:32:42 +01:00
|
|
|
- name: Push the image to the registry
|
2024-11-03 18:31:25 +01:00
|
|
|
if: fromJSON(steps.builder.outputs.run)
|
2024-11-09 02:32:42 +01:00
|
|
|
uses: actions/push-to-registry@v2
|
2024-10-25 13:51:15 +02:00
|
|
|
with:
|
2024-12-05 18:51:22 +01:00
|
|
|
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
|
2024-10-25 13:51:15 +02:00
|
|
|
image: treetrail-frontend
|
2024-11-02 18:41:14 +01:00
|
|
|
tags: ${{ steps.version.outputs.version }}
|