Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ push operator images to gcr #1139

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/cnspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ on:
default: 'latest'

env:
IMAGE: ghcr.io/mondoohq/mondoo-operator/cnspec
GHCR_IMAGE: ghcr.io/mondoohq/mondoo-operator/cnspec
GCP_IMAGE: us-docker.pkg.dev/mondoohq/release/mondoo-operator-cnspec

jobs:
build-cnspec:
Expand Down Expand Up @@ -55,11 +56,27 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_ARTIFACT_REGISTRY_SA }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"

- name: Docker Login (GCR)
run: |
gcloud auth configure-docker us-docker.pkg.dev
- name: "Setup Docker Buildx"
uses: docker/setup-buildx-action@v3

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
images: |
${{ env.GHCR_IMAGE }}
${{ env.GCP_IMAGE }}
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
type=semver,pattern={{major}},value=${{ env.VERSION }}
Expand Down
54 changes: 41 additions & 13 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ on:
tags: ["v*.*.*"]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
GHCR_IMAGE: ghcr.io/${{ github.repository }}
GCP_IMAGE: us-docker.pkg.dev/mondoohq/release/${{ github.repository }}
RELEASE: ${{ github.ref_name }}

jobs:
Expand Down Expand Up @@ -69,13 +67,27 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_ARTIFACT_REGISTRY_SA }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"

- name: Docker Login (GCR)
run: |
gcloud auth configure-docker us-docker.pkg.dev

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.GHCR_IMAGE }}
${{ env.GCP_IMAGE }}
tags: |
type=schedule,pattern=main
type=ref,event=branch
Expand All @@ -90,7 +102,9 @@ jobs:
id: meta_clean
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.GHCR_IMAGE }}
${{ env.GCP_IMAGE }}
tags: |
type=schedule,pattern=main
type=ref,event=branch
Expand All @@ -117,7 +131,7 @@ jobs:
env:
MONDOO_CONFIG_BASE64: ${{ secrets.MONDOO_CLIENT }}
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push-operator.outputs.digest }}
image: ${{ env.GHCR_IMAGE }}@${{ steps.build-and-push-operator.outputs.digest }}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
Expand All @@ -127,7 +141,7 @@ jobs:
- name: Sign the published Docker image
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign -y ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push-operator.outputs.digest }}
run: cosign sign -y ${{ env.GHCR_IMAGE }}@${{ steps.build-and-push-operator.outputs.digest }}

push-virtual-tag:
name: Push multi-platform virtual tag
Expand Down Expand Up @@ -160,13 +174,27 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_ARTIFACT_REGISTRY_SA }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"

- name: Docker Login (GCR)
run: |
gcloud auth configure-docker us-docker.pkg.dev

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
${{ env.GHCR_IMAGE }}
${{ env.GCP_IMAGE }}

- name: Push multi-platform virtual tag and sign
run: bash scripts/push-virtual-tag.sh
Expand Down Expand Up @@ -231,15 +259,15 @@ jobs:
gpg -u "Operator SDK (release) <[email protected]>" --verify checksums.txt.asc
grep operator-sdk_${OS}_${ARCH} checksums.txt | sha256sum -c -
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
make bundle IMG='${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE }}' VERSION='${{ env.RELEASE }}'
make bundle IMG='${{ env.GHCR_IMAGE }}:${{ env.RELEASE }}' VERSION='${{ env.RELEASE }}'

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta-bundle
uses: docker/metadata-action@v5
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle"
images: "${{ env.GHCR_IMAGE }}-bundle"

# Build and push Docker image bundle with Buildx
- name: Build and push bundle image
Expand All @@ -261,7 +289,7 @@ jobs:
- name: Sign the published Docker image
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign -y ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle@${{ steps.build-and-push-bundle.outputs.digest }}
run: cosign sign -y ${{ env.GHCR_IMAGE }}-bundle@${{ steps.build-and-push-bundle.outputs.digest }}

# run olm e2e tests
run-olm-e2e:
Expand Down Expand Up @@ -332,7 +360,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.GHCR_IMAGE }}

- name: Run integration tests
env:
Expand Down
Loading