Merge core/ci repo into go-devops: - cmd/ci: release publish, init, changelog, version commands - cmd/sdk: API diff and OpenAPI validation commands Add reusable Forgejo Actions workflows: - security-scan.yml: govulncheck + gitleaks + trivy - go-test.yml: test with optional race/coverage - docker-publish.yml: build + push to registry Other repos can call these via: uses: core/go-devops/.forgejo/workflows/security-scan.yml@main Co-Authored-By: Virgil <virgil@lethean.io>
50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
# Reusable Docker build and publish workflow
|
|
# Usage: uses: core/go-devops/.forgejo/workflows/docker-publish.yml@main
|
|
|
|
name: Docker Publish
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
image:
|
|
description: Image name (e.g. host-uk/app)
|
|
type: string
|
|
required: true
|
|
dockerfile:
|
|
description: Path to Dockerfile
|
|
type: string
|
|
default: Dockerfile
|
|
context:
|
|
description: Docker build context
|
|
type: string
|
|
default: '.'
|
|
registry:
|
|
description: Container registry
|
|
type: string
|
|
default: dappco.re/osi
|
|
secrets:
|
|
REGISTRY_USER:
|
|
required: true
|
|
REGISTRY_TOKEN:
|
|
required: true
|
|
|
|
jobs:
|
|
build-push:
|
|
name: Build & Push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ inputs.registry }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
|
|
|
- name: Build and push
|
|
run: |
|
|
SHA=$(git rev-parse --short HEAD)
|
|
docker build \
|
|
-f ${{ inputs.dockerfile }} \
|
|
-t ${{ inputs.registry }}/${{ inputs.image }}:${SHA} \
|
|
-t ${{ inputs.registry }}/${{ inputs.image }}:latest \
|
|
${{ inputs.context }}
|
|
docker push ${{ inputs.registry }}/${{ inputs.image }}:${SHA}
|
|
docker push ${{ inputs.registry }}/${{ inputs.image }}:latest
|