Skip to content

Commit 82ce443

Browse files
ci: Also package plugin in a container (#102)
Signed-off-by: Kostis (Codefresh) <39800303+kostis-codefresh@users.noreply.github.com>
1 parent 473890c commit 82ce443

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish to GitHub packages
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
# Allow creating a container image at any time (even without a tag)
10+
workflow_dispatch:
11+
push:
12+
# Publish semver tags as releases.
13+
tags: [ 'v*.*.*' ]
14+
15+
env:
16+
# Use docker.io for Docker Hub if empty
17+
REGISTRY: ghcr.io
18+
# github.repository as <account>/<repo>
19+
IMAGE_NAME: ${{ github.repository }}
20+
21+
22+
jobs:
23+
build:
24+
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
# This is used to complete the identity challenge
30+
# with sigstore/fulcio when running outside of PRs.
31+
id-token: write
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
37+
# Install the cosign tool except on PR
38+
# https://github.com/sigstore/cosign-installer
39+
- name: Install cosign
40+
if: github.event_name != 'pull_request'
41+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
42+
with:
43+
cosign-release: 'v2.2.4'
44+
45+
# Set up BuildKit Docker container builder to be able to build
46+
# multi-platform images and export cache
47+
# https://github.com/docker/setup-buildx-action
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
50+
51+
# Login against a Docker registry except on PR
52+
# https://github.com/docker/login-action
53+
- name: Log into registry ${{ env.REGISTRY }}
54+
if: github.event_name != 'pull_request'
55+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
56+
with:
57+
registry: ${{ env.REGISTRY }}
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
# Extract metadata (tags, labels) for Docker
62+
# https://github.com/docker/metadata-action
63+
- name: Extract Docker metadata
64+
id: meta
65+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
66+
with:
67+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+
69+
# Build and push Docker image with Buildx (don't push on PR)
70+
# https://github.com/docker/build-push-action
71+
- name: Build and push Docker image
72+
id: build-and-push
73+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
74+
with:
75+
context: .
76+
push: ${{ github.event_name != 'pull_request' }}
77+
platforms: linux/amd64,linux/arm64
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
83+
# Sign the resulting Docker image digest except on PRs.
84+
# This will only write to the public Rekor transparency log when the Docker
85+
# repository is public to avoid leaking data. If you would like to publish
86+
# transparency data even for private images, pass --force to cosign below.
87+
# https://github.com/sigstore/cosign
88+
- name: Sign the published Docker image
89+
if: ${{ github.event_name != 'pull_request' }}
90+
env:
91+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
92+
TAGS: ${{ steps.meta.outputs.tags }}
93+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
94+
# This step uses the identity token to provision an ephemeral certificate
95+
# against the sigstore community Fulcio instance.
96+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/release.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,10 @@ jobs:
153153
asset_name: gatewayapi-plugin-windows-amd64.exe
154154
asset_content_type: application/octet-stream
155155
if: ${{ env.IS_DRY_RUN != 'true' }}
156+
157+
- name: Create Container image
158+
run: |
159+
echo "Building containers for ${RELEASE_TAG}"
160+
gh workflow run docker-publish.yaml --ref ${RELEASE_TAG}
161+
env:
162+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)