treetrail-frontend/.forgejo/workflows/build.yaml

94 lines
2.7 KiB
YAML
Raw Normal View History

2024-10-25 13:51:15 +02:00
on:
push:
workflow_dispatch:
inputs:
build:
description: "Build container"
2024-11-09 02:32:42 +01:00
required: true
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
with:
fetch-depth: 0
- 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
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"
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
- name: Build package (transpile ts => js)
run: ng build
- name: Build container
if: fromJSON(steps.builder.outputs.run)
2024-10-25 13:55:33 +02:00
uses: actions/buildah-build@v1
with:
image: treetrail-frontend
2024-11-03 02:50:12 +01:00
oci: true
labels: treetrail-frontend
tags: ${{ steps.version.outputs.version }}
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
if: fromJSON(steps.builder.outputs.run)
2024-11-01 06:34:41 +01:00
run: |
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)
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
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
tags: ${{ steps.version.outputs.version }}