forked from bohlenc/k8s-pod-mutator-webhook
-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (73 loc) · 2.24 KB
/
publish-image-webhook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Container: Image Build Webhook"
on:
workflow_dispatch: {}
pull_request:
branches: ["main"]
types: ["opened", "synchronize", "reopened"]
paths:
- .github/workflows/publish-image-webhook.yaml
- "build/webhook/**/*"
- "cmd/webhook/**/*"
- "pkg/**/*"
- "internal/**/*"
- "go.**"
- ".dockerignore"
push:
tags:
- 'k8s-pod-mutator-webhook-v*'
branches:
- main
paths:
- .github/workflows/publish-image-webhook.yaml
- "build/webhook/**/*"
- "cmd/webhook/**/*"
- "pkg/**/*"
- "internal/**/*"
- "go.**"
- ".dockerignore"
jobs:
publish-images:
name: Publish Image
permissions:
contents: write
packages: write
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/webhook
tags: |
type=ref,event=pr
type=schedule
type=match,pattern=\d.\d.\d
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log into registry ghcr.io
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./
file: ./build/webhook/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}