name: Publish container image on: push: tags: - "v*.*.*" env: REGISTRY: 192.168.0.86:3000 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: Configure Gitea registry credentials shell: bash env: REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} run: | mkdir -p "${HOME}/.docker" auth="$(printf '%s:%s' "${REGISTRY_USERNAME}" "${REGISTRY_TOKEN}" | base64 | tr -d '\n')" printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${REGISTRY}" "${auth}" > "${HOME}/.docker/config.json" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: buildkitd-config-inline: | [registry."192.168.0.86:3000"] http = true insecure = true - name: Build and publish uses: docker/build-push-action@v6 with: context: . push: true build-args: | COMMIT_ID=${{ github.sha }} NGINX_BASE=${{ env.REGISTRY }}/hiyv-demo/nginx-base:1.28-alpine-amd64 tags: ${{ steps.tags.outputs.tags }} labels: | org.opencontainers.image.version=${{ steps.tags.outputs.version }} org.opencontainers.image.revision=${{ github.sha }} org.opencontainers.image.source=https://git.mancheff.com/${{ github.repository }} platforms: linux/amd64