From f1ebc3bd78dc84ca6f41a2b9d662bba175fd4562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Schw=C3=A4gerl?= Date: Tue, 5 Mar 2024 13:31:05 +0100 Subject: [PATCH] use cache instead of env variables for passing the manifests --- .github/workflows/check-manifest-diffs.yaml | 54 +++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/check-manifest-diffs.yaml b/.github/workflows/check-manifest-diffs.yaml index 7c02f1f6f57..2a757b9fda7 100644 --- a/.github/workflows/check-manifest-diffs.yaml +++ b/.github/workflows/check-manifest-diffs.yaml @@ -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" ] @@ -15,40 +18,48 @@ 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<> "$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<> "$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 @@ -56,16 +67,19 @@ jobs: 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."