# Template action to generate OCI-compliant containers # Don't forget to change the template variables if any were missed name: Build and Publish Container on: push: tags: - 'v*' jobs: build-and-push: runs-on: alpine-latest steps: - name: Install Dependencies shell: sh run: apk add --no-cache bash docker-cli docker-cli-buildx git - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # Get full git history - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: ${{ secrets.REGISTRY }} username: ${{ secrets.USERNAME }} password: ${{ secrets.TOKEN }} - name: Normalize release version id: version shell: sh run: | ORG_REPO="$(printf '%s' "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')" echo "image_base=${{ secrets.REGISTRY }}/${ORG_REPO}" >> "${GITHUB_OUTPUT}" TAG="${GITHUB_REF_NAME#v}" PRERELEASE="" case "$TAG" in *-*) PRERELEASE="-${TAG#*-}"; TAG="${TAG%%-*}";; esac IFS='.' read -r MAJOR MINOR PATCH <> "${GITHUB_OUTPUT}" - name: Extract metadata (labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ steps.version.outputs.image_base }} labels: | org.opencontainers.image.title=Test Service org.opencontainers.image.vendor=Dcntrlized org.opencontainers.image.description=A test service used to test service creation and deployment org.opencontainers.image.authors=Admin org.opencontainers.image.version=${{ steps.version.outputs.version }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: true tags: | ${{ steps.version.outputs.image_base }}:${{ steps.version.outputs.version }} ${{ steps.version.outputs.image_base }}:latest labels: ${{ steps.meta.outputs.labels }} build-args: | IMAGE_VERSION=${{ steps.version.outputs.version }} IMAGE_REVISION=${{ gitea.sha }}