Skip to content

Commit

Permalink
use cache instead of env variables for passing the manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-pius committed Mar 5, 2024
1 parent c2e55eb commit f1ebc3b
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions .github/workflows/check-manifest-diffs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: "Check for diff in manifests"

env:
CACHE_KEY: manifests-${{ env.GITHUB_RUN_ID }}-${{ env.GITHUB_RUN_ATTEMPT }}

on:
pull_request:
branches: [ "main" ]
Expand All @@ -15,57 +18,68 @@ jobs:
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-control-plane'
id: make-pr-manifests
run: |
sudo mkdir -p /cache/pr
make dry-run-control-plane
{
echo 'manifests<<EOF'
cat ./dry-run/manifests.yaml
echo EOF
} >> "$GITHUB_OUTPUT"
sudo mv ./dry-run/manifests.yaml /cache/pr/manifests.yaml
- name: Save PR manifests in cache
id: cache-pr-manifests
uses: actions/cache/save@v3
with:
path: /cache
key: ${{ CACHE_KEY }}

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-control-plane'
id: make-main-manifests
run: |
sudo mkdir -p /cache/main
make dry-run-control-plane
{
echo 'manifests<<EOF'
cat ./dry-run/manifests.yaml
echo EOF
} >> "$GITHUB_OUTPUT"
sudo mv ./dry-run/manifests.yaml /cache/main/manifests.yaml
- name: Save 'main' manifests in cache
id: cache-main-manifests
uses: actions/cache/save@v3
with:
path: /cache
key: ${{ CACHE_KEY }}

diff-manifests:
needs:
- create-pr-manifests
- create-main-manifests
name: Diff manifests
runs-on: ubuntu-latest
steps:
- name: Restore manifests cache
uses: actions/cache/restore@v3
id: restore-cache
with:
path: /cache
key: ${{ CACHE_KEY }}

- 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
ls /cache
set +e
SCRIPT_OUTPUT=$(diff ./prManifests.yaml ./mainManifests.yaml)
SCRIPT_OUTPUT=$(diff ./cache/pr/manifests.yaml ./cache/main/manifests.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."
Expand Down

0 comments on commit f1ebc3b

Please sign in to comment.