Skip to content

Commit

Permalink
feat: verify Kustomize diff
Browse files Browse the repository at this point in the history
  • Loading branch information
c-pius committed Mar 4, 2024
1 parent bc207ab commit 59c7d18
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 3 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/check-manifest-diffs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: "Check for diff in manifests"

on:
pull_request:
branches: [ "main" ]
types:
- "opened"
- "synchronize"
- "reopened"
- "labeled"
- "unlabeled"

jobs:
create-pr-manifests:
if: ${{ contains(github.event.pull_request.labels.*.name, 'confirm/helm-update') == false }}
name: Create PR manifests
runs-on: ubuntu-latest
outputs:
manifests: ${{ steps.make-pr-manifests.outputs.manifests }}
steps:
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
- name: Run 'make dry-run'
id: make-pr-manifests
run: |
make dry-run
{
echo 'manifests<<EOF'
cat ./dry-run/manifests.yaml
echo EOF
} >> "$GITHUB_OUTPUT"
create-main-manifests:
if: ${{ contains(github.event.pull_request.labels.*.name, 'confirm/helm-update') == false }}
name: Create 'main' manifests
runs-on: ubuntu-latest
outputs:
manifests: ${{ steps.make-main-manifests.outputs.manifests }}
steps:
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
with:
ref: main
- name: Run 'make dry-run'
id: make-main-manifests
run: |
make dry-run
{
echo 'manifests<<EOF'
cat ./dry-run/manifests.yaml
echo EOF
} >> "$GITHUB_OUTPUT"
diff-manifests:
needs:
- create-pr-manifests
- create-main-manifests
name: Diff manifests
runs-on: ubuntu-latest
steps:
- name: Diff
env:
PR_MANIFESTS: ${{needs.create-pr-manifests.outputs.manifests}}
MAIN_MANIFESTS: ${{needs.create-main-manifests.outputs.manifests}}
run: |
echo "$PR_MANIFESTS" >> ./prManifests.yaml
echo "$MAIN_MANIFESTS" >> ./mainManifests.yaml
set +e
SCRIPT_OUTPUT=$(diff ./prManifests.yaml ./mainManifests.yaml)
SCRIPT_EXIT_CODE=$?
if [[ $SCRIPT_EXIT_CODE != 0 ]]; then
echo "Detected diff in manifests. Make sure to update Helm charts accordingly and add the'confirm/helm-update' label to the PR when okay."
echo "$SCRIPT_OUTPUT"
exit $SCRIPT_EXIT_CODE
fi
set -e
echo "No diff in manifests, all good."
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# Adds namespace to all resources.
namespace: kcp-system
namespace: foobar

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
Expand Down
3 changes: 1 addition & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ configMapGenerator:

images:
- name: controller
newName: europe-docker.pkg.dev/kyma-project/prod/lifecycle-manager
newTag: latest
newName: /lifecycle-manager

0 comments on commit 59c7d18

Please sign in to comment.