From 804636c2f9df8fbeb27c4f22d54e5cdb99ea4688 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 13:31:39 -0700 Subject: [PATCH] return 2 --- .../workflows/hybrid_branch_deployments.yml | 3 + actions/hybrid_branch_deploy/action.yml | 61 ++++++++++--------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.github/workflows/hybrid_branch_deployments.yml b/.github/workflows/hybrid_branch_deployments.yml index 0e52209a..959e4a11 100644 --- a/.github/workflows/hybrid_branch_deployments.yml +++ b/.github/workflows/hybrid_branch_deployments.yml @@ -22,6 +22,9 @@ jobs: dagster_cloud_build_push: runs-on: ubuntu-latest needs: parse_workspace + permissions: + contents: read + pull-requests: read name: Dagster Hybrid Branch Deployments strategy: fail-fast: false diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 7f760f2b..9f9026ce 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -30,6 +30,37 @@ runs: ref: ${{ github.sha }} fetch-depth: 100 + - name: Get git sha + id: get_shas + run: git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }} + shell: bash + + - uses: actions/github-script@v7 + id: get_prs + env: + # Input the output of the previous step + PREVIOUS_SHA: ${{ steps.get_shas.outputs.stdout }} + with: + script: | + const previousShas = process.env.PREVIOUS_SHA.split('\n').map(s => s.trim()).filter(s => s.length > 0); + let pullRequests = []; + for (const sha of previousShas) { + const pr = await github.rest.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: sha, + owner: context.repo.owner, + repo: context.repo.repo, + }); + if (pr.data.length > 0) { + pullRequests.push(...pr.data); + } + } + return pullRequests; + + - name: Print PRs + run: echo "${{ steps.get_prs.outputs.result }}" + shell: bash + + - name: Checkout action repo uses: actions/checkout@v3 with: @@ -84,36 +115,6 @@ runs: env: DAGSTER_CLOUD_API_TOKEN: ${{ inputs.dagster_cloud_api_token }} - - name: Get git sha - id: get_shas - run: git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }} - shell: bash - - - uses: actions/github-script@v7 - id: get_prs - env: - # Input the output of the previous step - PREVIOUS_SHA: ${{ steps.get_shas.outputs.stdout }} - with: - script: | - const previousShas = process.env.PREVIOUS_SHA.split('\n').map(s => s.trim()).filter(s => s.length > 0); - let pullRequests = []; - for (const sha of previousShas) { - const pr = await github.rest.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: sha, - owner: context.repo.owner, - repo: context.repo.repo, - }); - if (pr.data.length > 0) { - pullRequests.push(...pr.data); - } - } - return pullRequests; - - - name: Print PRs - run: echo "${{ steps.get_prs.outputs.result }}" - shell: bash - # Optional steps, leaves PR comment about build status - name: Notify build success uses: ./action-repo/actions/utils/notify