64 lines
1.8 KiB
YAML
64 lines
1.8 KiB
YAML
name: Publish container image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
env:
|
|
REGISTRY: git.mancheff.com
|
|
IMAGE_NAME: hiyv-demo/hiyv-nginx
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Check out source
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Derive image tags
|
|
id: tags
|
|
shell: bash
|
|
run: |
|
|
version="${GITHUB_REF_NAME#v}"
|
|
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
echo "Tag ${GITHUB_REF_NAME} is not a semantic version (vMAJOR.MINOR.PATCH)." >&2
|
|
exit 1
|
|
fi
|
|
major_minor="${version%.*}"
|
|
major="${version%%.*}"
|
|
image="${REGISTRY}/${IMAGE_NAME}"
|
|
{
|
|
echo "version=${version}"
|
|
echo "image=${image}"
|
|
echo "tags=${image}:${version},${image}:${major_minor},${image}:${major},${image}:${GITHUB_SHA},${image}:latest"
|
|
} >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Log in to the Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and publish
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
build-args: |
|
|
COMMIT_ID=${{ github.sha }}
|
|
tags: ${{ steps.tags.outputs.tags }}
|
|
labels: |
|
|
org.opencontainers.image.version=${{ steps.tags.outputs.version }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
platforms: linux/amd64
|