Skip to content
Open
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
86 changes: 86 additions & 0 deletions .github/workflows/build-pr-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build PR image

on:
pull_request:
branches: [main]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'Dockerfile'

jobs:
ci:
uses: ./.github/workflows/ci.yml

build_pr_image:
needs: ci
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: snowdrop/cert-manager-webhook-godaddy
tags: pr-${{ github.event.pull_request.number }}
enableBuildKit: true
multiPlatform: true
platform: linux/amd64,linux/arm64
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USER }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const tag = `pr-${{ github.event.pull_request.number }}`;
const image = `quay.io/snowdrop/cert-manager-webhook-godaddy:${tag}`;
const body = `### Test image ready

\`${image}\`

**To test on a kind cluster:**

\`\`\`fish
# Pull, save, and load into kind
podman pull ${image}
podman save ${image} -o /tmp/webhook-pr.tar
kind load image-archive /tmp/webhook-pr.tar --name cert-manager-test
rm /tmp/webhook-pr.tar

# Install or upgrade the webhook
helm upgrade --install -n cert-manager godaddy-webhook ./deploy/charts/godaddy-webhook \\
--set groupName=\\$DOMAIN \\
--set image.tag=${tag} \\
--set image.pullPolicy=Never
\`\`\``;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes('### Test image ready'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
name: Build and push godaddy webhook image
name: Build and push GoDaddy webhook image
on:
pull_request:
branches: [ main ]
push:
branches:
- main
branches: [main]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'Dockerfile'
workflow_dispatch:

jobs:
ci:
uses: ./.github/workflows/ci.yml

build_push_image:
needs: ci
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v5

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Build
run: go build ./...

test-unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run unit tests
run: go test -v -race ./internal/...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ webhook
# Ignore the built binary
cert-manager-webhook-godaddy
/vendor/
/testdata/godaddy/secret.yaml
/testdata/godaddy/*/secret.yaml
cmd.md
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,35 @@ $(shell mkdir -p "$(OUT)")

clean:
rm -rf vendor
rm -Rf $(OUT)
chmod -R u+w $(OUT) 2>/dev/null || true
rm -rf $(OUT)
rm -rf apiserver.local.config

install-tools:
sh ./scripts/fetch-test-binaries.sh

test-v1:
go test -v ./internal/godaddy/v1/

test-v3:
go test -v ./internal/godaddy/v3/

test-unit:
go test -v ./internal/...

verify: clean install-tools
go test -v .

TEST_API_VERSION ?= v1

test: clean install-tools
TEST_ASSET_ETCD=$(OUT)/kubebuilder/bin/etcd \
TEST_ASSET_KUBECTL=$(OUT)/kubebuilder/bin/kubectl \
TEST_ASSET_KUBE_APISERVER=$(OUT)/kubebuilder/bin/kube-apiserver \
TEST_ZONE_NAME=$(TEST_ZONE_NAME) \
TEST_DNS_SERVER=$(TEST_DNS_SERVER) go test .
TEST_DNS_SERVER=$(TEST_DNS_SERVER) \
TEST_API_VERSION=$(TEST_API_VERSION) \
TEST_TIMEOUT=$(TEST_TIMEOUT) go test .

compile:
echo "### Go mod vendor ..."
Expand Down
Loading
Loading