All checks were successful
Deploy to K8s / deploy (push) Successful in 14s
github.event.workflow_run.head_branch is not populated for tag pushes in Gitea Actions, causing the image tag to resolve to empty (-go suffix with no version). Fix: build-go uploads the full image reference as a one-line artifact; gitops-update downloads it via download-artifact@v4 with run-id from the workflow_run event. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
name: Build and Push
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Image tag'
|
|
required: true
|
|
default: 'latest'
|
|
push:
|
|
tags:
|
|
- '*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login -u ${{ github.actor }} --password-stdin gitea.home.hrajfrisbee.cz
|
|
|
|
- name: Build and push
|
|
run: |
|
|
TAG=${{ github.ref_name }}
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
TAG=${{ inputs.tag }}
|
|
fi
|
|
IMAGE=gitea.home.hrajfrisbee.cz/${{ github.repository }}:$TAG
|
|
docker build -f build/Dockerfile \
|
|
--build-arg GIT_TAG=$TAG \
|
|
--build-arg GIT_COMMIT=${{ github.sha }} \
|
|
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
|
|
-t $IMAGE .
|
|
docker push $IMAGE
|
|
|
|
build-go:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login -u ${{ github.actor }} --password-stdin gitea.home.hrajfrisbee.cz
|
|
|
|
- name: Build and push Go image
|
|
run: |
|
|
TAG=${{ github.ref_name }}
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
TAG=${{ inputs.tag }}
|
|
fi
|
|
IMAGE=gitea.home.hrajfrisbee.cz/${{ github.repository }}:$TAG-go
|
|
docker build -f go/build/Dockerfile \
|
|
--build-arg GIT_TAG=$TAG \
|
|
--build-arg GIT_COMMIT=${{ github.sha }} \
|
|
--build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
|
|
-t $IMAGE go/
|
|
docker push $IMAGE
|
|
echo "$IMAGE" > /tmp/go-image-tag.txt
|
|
|
|
- name: Upload Go image tag for gitops workflow
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: go-image-tag
|
|
path: /tmp/go-image-tag.txt
|
|
retention-days: 1
|