From 59178b5aec2645af838b5e3ed104b0abf0850369 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 12:49:14 -0700 Subject: [PATCH 1/7] test get prs --- actions/hybrid_branch_deploy/action.yml | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 18c4c95a..40f098d2 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -83,6 +83,34 @@ 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.sha }} + + - 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); + } + } + reutrn pullRequests; + + - name: Print PRs + run: echo "${{ steps.get_prs.outputs.result }}" + # Optional steps, leaves PR comment about build status - name: Notify build success uses: ./action-repo/actions/utils/notify From 0afb493601452b914bf6a6354a29b61086107dd2 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 12:56:39 -0700 Subject: [PATCH 2/7] shell --- actions/hybrid_branch_deploy/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 40f098d2..fc296589 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -28,6 +28,7 @@ runs: uses: actions/checkout@v3 with: ref: ${{ github.sha }} + fetch-depth: 100 - name: Checkout action repo uses: actions/checkout@v3 @@ -85,7 +86,8 @@ runs: - name: Get git sha id: get_shas - run: git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.sha }} + run: git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }} + shell: bash - uses: actions/github-script@v7 id: get_prs @@ -110,6 +112,7 @@ runs: - name: Print PRs run: echo "${{ steps.get_prs.outputs.result }}" + shell: bash # Optional steps, leaves PR comment about build status - name: Notify build success From 5e7846bb30325e6cf4a9c61603d7b5190cba6a1a Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 13:24:25 -0700 Subject: [PATCH 3/7] return --- actions/hybrid_branch_deploy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index fc296589..7f760f2b 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -108,7 +108,7 @@ runs: pullRequests.push(...pr.data); } } - reutrn pullRequests; + return pullRequests; - name: Print PRs run: echo "${{ steps.get_prs.outputs.result }}" From 804636c2f9df8fbeb27c4f22d54e5cdb99ea4688 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 13:31:39 -0700 Subject: [PATCH 4/7] 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 From 50cf490f4ad903254d38952e18fa1ba0d95ffbb1 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 13:38:52 -0700 Subject: [PATCH 5/7] log --- actions/hybrid_branch_deploy/action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 9f9026ce..8b1f87c1 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -32,17 +32,18 @@ runs: - name: Get git sha id: get_shas - run: git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }} + run: echo "SHAS<> $GITHUB_OUTPUT 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 }} + PREVIOUS_SHAS: ${{ steps.get_shas.outputs.SHAS }} with: script: | - const previousShas = process.env.PREVIOUS_SHA.split('\n').map(s => s.trim()).filter(s => s.length > 0); + const previousShas = process.env.PREVIOUS_SHAS.split('\n').map(s => s.trim()).filter(s => s.length > 0); + console.log(previousShas); let pullRequests = []; for (const sha of previousShas) { const pr = await github.rest.repos.listPullRequestsAssociatedWithCommit({ @@ -50,10 +51,12 @@ runs: owner: context.repo.owner, repo: context.repo.repo, }); + console.log(pr); if (pr.data.length > 0) { pullRequests.push(...pr.data); } } + console.log(pullRequests); return pullRequests; - name: Print PRs From ca52f77f78cb001c1876039a39518f647f44b207 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 14:18:26 -0700 Subject: [PATCH 6/7] why --- actions/hybrid_branch_deploy/action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 8b1f87c1..371612c9 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -28,11 +28,14 @@ runs: uses: actions/checkout@v3 with: ref: ${{ github.sha }} - fetch-depth: 100 + fetch-depth: 500 - name: Get git sha id: get_shas - run: echo "SHAS<> $GITHUB_OUTPUT + run: | + echo "SHAS<> $GITHUB_OUTPUT + echo "$(git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT shell: bash - uses: actions/github-script@v7 From a32be0eae7d27225fdd2e98f507416c5b37715d6 Mon Sep 17 00:00:00 2001 From: benpankow Date: Wed, 10 Jul 2024 14:24:16 -0700 Subject: [PATCH 7/7] no log --- actions/hybrid_branch_deploy/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/actions/hybrid_branch_deploy/action.yml b/actions/hybrid_branch_deploy/action.yml index 371612c9..749c8f79 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -34,7 +34,7 @@ runs: id: get_shas run: | echo "SHAS<> $GITHUB_OUTPUT - echo "$(git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT + git rev-list --ancestry-path cd2a864d09faa69900bff468f0f78d7e630ff87b..${{ github.event.pull_request.head.sha }} >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT shell: bash @@ -54,9 +54,8 @@ runs: owner: context.repo.owner, repo: context.repo.repo, }); - console.log(pr); if (pr.data.length > 0) { - pullRequests.push(...pr.data); + pullRequests.push(...pr.data.map(p => p.number)); } } console.log(pullRequests);