From 66bfe6a6e5e44248a17468c36f1cf4284f97cf29 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Wed, 31 May 2023 16:09:23 +0300 Subject: [PATCH] Look for /update-sdk in PR description Signed-off-by: Gabriel Adrian Samfira --- .../pr-comment-build-dispatcher.yaml | 27 +++----------- .github/workflows/pr-workflows.yaml | 37 ++++++++----------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/.github/workflows/pr-comment-build-dispatcher.yaml b/.github/workflows/pr-comment-build-dispatcher.yaml index f6396973b6..4110d351bd 100644 --- a/.github/workflows/pr-comment-build-dispatcher.yaml +++ b/.github/workflows/pr-comment-build-dispatcher.yaml @@ -13,11 +13,11 @@ concurrency: jobs: run_pre_checks: # Only run if this is a PR comment that contains a valid command - if: ${{ github.event.issue.pull_request }} && contains(github.event.comment.body, '/build-image') + if: ${{ github.event.issue.pull_request }} && ( contains(github.event.comment.body, '/build-image') || contains(github.event.comment.body, '/update-sdk')) name: Check if commenter is in the Flatcar maintainers team outputs: maintainers: steps.step1.output.maintainers - sdk_changes: steps.step3.outputs.sdk_changes + sdk_changes: ${{ steps.step3.outputs.sdk_changes }} runs-on: - ubuntu-latest steps: @@ -49,29 +49,14 @@ jobs: $res - - uses: actions/checkout@v3 - id: step2 - with: - path: scripts - fetch-depth: 0 - - - uses: dorny/paths-filter@v2 - id: filter - with: - working-directory: scripts - filters: | - sdk_changes: - - 'sdk_container/**' - - 'sdk_libs/**' - - name: Set outputs - id: step3 + id: step2 shell: bash run: | - echo "sdk_changes=${{ steps.filter.outputs.sdk_changes }}" >> $GITHUB_OUTPUT + echo "sdk_changes=${{ contains(github.event.comment.body, '/update-sdk') }}" >> $GITHUB_OUTPUT - name: Post a link to the workflow run to the PR - id: step4 + id: step3 uses: mshick/add-pr-comment@v2 with: issue: ${{ github.event.issue.pull_request.number }} @@ -87,7 +72,7 @@ jobs: build_image: needs: [ run_pre_checks, update_sdk ] - if: (always() && ! cancelled()) && needs.run_pre_checks.result == 'success' && contains(github.event.comment.body, '/build-image') + if: (always() && ! cancelled()) && needs.run_pre_checks.result == 'success' && needs.update_sdk.result != 'failure' && contains(github.event.comment.body, '/build-image') name: "Build the OS image" uses: ./.github/workflows/ci.yaml with: diff --git a/.github/workflows/pr-workflows.yaml b/.github/workflows/pr-workflows.yaml index 6d0d32305c..6a8302f3e2 100644 --- a/.github/workflows/pr-workflows.yaml +++ b/.github/workflows/pr-workflows.yaml @@ -10,44 +10,37 @@ concurrency: cancel-in-progress: true jobs: - check_for_sdk_changes: - name: "Check for SDK changes" + pre_check: + name: "Check if we need to update the SDK" runs-on: ubuntu-latest + # Setting the environment is the more important reason we need this job. + # We use this job as a gate, so we can approve the PR workflow only once. If + # we set this in the update_sdk job and in the build_image job, we would have + # to approve the workflow for every job that kicks off. Given that the jobs + # are sequenced, this is cumbersome. Use this job as a gate and make the rest + # dependent on it. environment: development outputs: - sdk_changes: ${{ steps.step2.outputs.sdk_changes }} + sdk_changes: ${{ steps.step1.outputs.sdk_changes }} steps: - - uses: actions/checkout@v3 - id: step1 - with: - path: scripts - fetch-depth: 0 - - - uses: dorny/paths-filter@v2 - id: filter - with: - working-directory: scripts - filters: | - sdk_changes: - - 'sdk_container/**' - - 'sdk_libs/**' - - name: Set outputs - id: step2 + id: step1 shell: bash run: | - echo "sdk_changes=${{ steps.filter.outputs.sdk_changes }}" >> $GITHUB_OUTPUT + echo "sdk_changes=${{ contains(github.event.pull_request.body, '/update-sdk') }}" >> $GITHUB_OUTPUT update_sdk: name: "Build an updated SDK container" - needs: [ check_for_sdk_changes ] - if: needs.check_for_sdk_changes.sdk_changes == 'true' + needs: [ pre_check ] + if: needs.pre_check.outputs.sdk_changes == 'true' # SDK build needs access to bincache ssh secret secrets: inherit uses: ./.github/workflows/update-sdk.yaml build_image: needs: [ update_sdk ] + # The update-sdk job may be skipped, which is fine. We only care if it tried to + # run, but failed. if: (always() && ! cancelled()) && needs.update_sdk.result != 'failure' name: "Build the OS image" uses: ./.github/workflows/ci.yaml