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 18c4c95a..749c8f79 100644 --- a/actions/hybrid_branch_deploy/action.yml +++ b/actions/hybrid_branch_deploy/action.yml @@ -28,6 +28,43 @@ runs: uses: actions/checkout@v3 with: ref: ${{ github.sha }} + fetch-depth: 500 + + - name: Get git sha + id: get_shas + run: | + echo "SHAS<> $GITHUB_OUTPUT + 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 + id: get_prs + env: + # Input the output of the previous step + PREVIOUS_SHAS: ${{ steps.get_shas.outputs.SHAS }} + with: + script: | + 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({ + commit_sha: sha, + owner: context.repo.owner, + repo: context.repo.repo, + }); + if (pr.data.length > 0) { + pullRequests.push(...pr.data.map(p => p.number)); + } + } + console.log(pullRequests); + return pullRequests; + + - name: Print PRs + run: echo "${{ steps.get_prs.outputs.result }}" + shell: bash + - name: Checkout action repo uses: actions/checkout@v3