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

Add release workflow to publish docker image #2

Merged
merged 9 commits into from
Dec 7, 2023
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
121 changes: 121 additions & 0 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Artifacts

on:
workflow_call:
inputs:
publish:
description: Publish artifacts to the artifact store
default: false
required: false
type: boolean
outputs:
container-image-name:
description: Container image name
value: ${{ jobs.container-image.outputs.name }}
container-image-digest:
description: Container image digest
value: ${{ jobs.container-image.outputs.digest }}
container-image-ref:
description: Container image ref
value: ${{ jobs.container-image.outputs.ref }}

permissions:
contents: read

jobs:
container-image:
name: Container image
runs-on: ubuntu-latest

strategy:
matrix:
variant:
- alpine
# - distroless

permissions:
contents: read
packages: write
id-token: write
security-events: write

outputs:
name: ${{ steps.image-name.outputs.value }}
digest: ${{ steps.build.outputs.digest }}
ref: ${{ steps.image-ref.outputs.value }}

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Set image name
id: image-name
run: echo "value=ghcr.io/${{ github.repository }}" >> "$GITHUB_OUTPUT"

- name: Gather build metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: |
${{ steps.image-name.outputs.value }}
dexidp/dex
flavor: |
latest = false
tags: |
type=ref,event=branch,enable=${{ matrix.variant == 'alpine' }}
type=ref,event=pr,prefix=pr-,enable=${{ matrix.variant == 'alpine' }}
type=semver,pattern={{raw}},enable=${{ matrix.variant == 'alpine' }}
type=raw,value=latest,enable=${{ github.ref_name == github.event.repository.default_branch && matrix.variant == 'alpine' }}
type=ref,event=branch,suffix=-${{ matrix.variant }}
type=ref,event=pr,prefix=pr-,suffix=-${{ matrix.variant }}
type=semver,pattern={{raw}},suffix=-${{ matrix.variant }}
type=raw,value=latest,enable={{is_default_branch}},suffix=-${{ matrix.variant }}
labels: |
org.opencontainers.image.documentation=https://github.com/sl1pm4t/dex-k8s-authenticator

# Multiple exporters are not supported yet
# See https://github.com/moby/buildkit/pull/2760
- name: Determine build output
uses: haya14busa/action-cond@1d6e8a12b20cdb4f1954feef9aa475b9c390cab5 # v1.1.1
id: build-output
with:
cond: ${{ inputs.publish }}
if_true: type=image,push=true
if_false: type=oci,dest=image.tar

- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
if: inputs.publish

- name: Build and push image
id: build
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BASE_IMAGE=${{ matrix.variant }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
COMMIT_HASH=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
outputs: ${{ steps.build-output.outputs.value }}
push: ${{ inputs.publish }}

- name: Set image ref
id: image-ref
run: echo "value=${{ steps.image-name.outputs.value }}@${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT"

16 changes: 12 additions & 4 deletions .github/workflows/k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: k8s-lint
on:
push:
branches:
- master
- main
pull_request:
jobs:
Expand All @@ -21,6 +20,7 @@ jobs:
kubeconform: latest
kubeval: latest
helm: latest
stern: latest
jq: latest
yq: latest

Expand All @@ -41,6 +41,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: alexellis/arkade-get@master
with:
kubectl: latest
stern: latest

# - name: Install curl
# run: sudo apt-get install -y curl

- name: setup-kind
uses: helm/[email protected]
with:
Expand Down Expand Up @@ -74,6 +82,6 @@ jobs:

- name: test
run: |
kubectl get pods
export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}")
curl -Lsf "http://${NODE_IP}:30000/login/my-cluster" | grep "Log in to Your Account"
kubectl get pods
export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}")
curl -Lsf "http://${NODE_IP}:30000/login/my-cluster" | grep "Log in to Your Account"
19 changes: 19 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release

on:
pull_request:

permissions:
contents: read

jobs:
build-image:
name: Artifacts
uses: ./.github/workflows/artifacts.yaml
with:
publish: false
permissions:
contents: read
packages: write
id-token: write
security-events: write
20 changes: 20 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release

on:
push:
tags: [ "*" ]

permissions:
contents: read

jobs:
artifacts:
name: Artifacts
uses: ./.github/workflows/artifacts.yaml
with:
publish: true
permissions:
contents: read
packages: write
id-token: write
security-events: write
1 change: 1 addition & 0 deletions charts/dex-k8s-authenticator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ spec:
path: {{ template "dex-k8s-authenticator.healthCheckPath" . }}
port: http
readinessProbe:
initialDelaySeconds: 20
httpGet:
path: {{ template "dex-k8s-authenticator.healthCheckPath" . }}
port: http
Expand Down
2 changes: 1 addition & 1 deletion charts/dex-k8s-authenticator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global:
replicaCount: 1

image:
repository: sl1pm4t/dex-k8s-authenticator
repository: ghcr.io/sl1pm4t/dex-k8s-authenticator
tag: 2.0.0
pullPolicy: Always

Expand Down
2 changes: 1 addition & 1 deletion docs/eks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Required Charts
- nginx-ingress-controller - https://github.com/helm/charts/tree/master/stable/nginx-ingress
- dex - https://github.com/helm/charts/tree/master/stable/dex
- kube-oidc-proxy - https://github.com/jetstack/kube-oidc-proxy/tree/master/deploy/charts/kube-oidc-proxy
- dex-k8s-authenticator - https://github.com/sl1pm4t/dex-k8s-authenticator/tree/master/charts
- dex-k8s-authenticator - https://github.com/sl1pm4t/dex-k8s-authenticator/tree/main/charts

You should also setup a DNS record that points to your nginx controller (load-balancer), and setup an AWS ACM certificate.

Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/helm/dex-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
service:
type: NodePort
port: 5556
nodePort: 30001
ports:
http:
nodePort: 30001

ingress:
enabled: true
Expand Down
Loading