Skip to content

added changes

added changes #50

name: Build and Push with Git Tag
on:
push:
tags:
- "*"
env:
REGISTRY: gcr.io/stackgen-gcp-marketplace
IMAGE_NAME: stackgen-deployer/deployer
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
- name: Configure Docker
run: gcloud auth configure-docker gcr.io,marketplace.gcr.io
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Docker Build and Push
uses: docker/build-push-action@v6
with:
context: "deployer-image"
platforms: 'linux/amd64'
tags: ${{ steps.meta.outputs.tags }}
push: true
provenance: false
labels: |
${{ steps.meta.outputs.labels }}
com.github.actions.name=${{ github.workflow }}
com.github.actions.description=${{ github.workflow }}
# Install crane for image mutation
- name: Install crane
run: |
curl -LO https://github.com/google/go-containerregistry/releases/download/v0.16.1/go-containerregistry_Linux_x86_64.tar.gz
tar -xvf go-containerregistry_Linux_x86_64.tar.gz crane
sudo mv crane /usr/local/bin/
# Annotate the image using crane mutate
- name: Annotate image with Marketplace Service Name
run: |
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
echo "Annotating image: $tag"
crane mutate $tag \
--annotation "com.googleapis.cloudmarketplace.product.service.name=services/stackgen-enterprise-platform-k8s-v2.endpoints.stackgen-gcp-marketplace.cloud.goog"
done
# Verify annotation
- name: Verify Annotation
run: |
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
echo "Verifying annotation for: $tag"
crane manifest $tag | jq '.annotations'
done