diff --git a/.github/workflows/chart-release-dispatcher.yaml b/.github/workflows/chart-release-dispatcher.yaml index 8e325cd327..10fc6cbdb0 100644 --- a/.github/workflows/chart-release-dispatcher.yaml +++ b/.github/workflows/chart-release-dispatcher.yaml @@ -26,12 +26,42 @@ jobs: run: | echo "branch=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + with: + token: ${{ secrets.my_pat }} + ref: ${{ steps.extract_branch.outputs.branch }} + fetch-depth: 0 + + - name: Get SHA of the branch + id: get_sha + run: | + branch_name=${{ steps.extract_branch.outputs.branch }} + sha=$(git rev-parse "refs/heads/$branch_name") + echo "GIT_SHA: $sha" + echo "sha=${sha}" >> $GITHUB_OUTPUT + - name: Extract Repository Name id: extract_repo_name run: | repo_name=$(basename $GITHUB_REPOSITORY) echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT + - name: Get PR url and PR User + id: get_pr_url_user + run: | + head_sha=$(curl -s -H "Authorization: Bearer ${{ secrets.my_pat }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/jobs" | jq -r '.jobs[0].head_sha') + echo "Head SHA: $head_sha" + pr_url=$(curl -s -H "Authorization: Bearer ${{ secrets.my_pat }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/search/issues?q=sha:$head_sha+type:pr" | jq -r '.items[0].html_url') + pr_user=$(curl -s -H "Authorization: Bearer ${{ secrets.my_pat }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/search/issues?q=sha:$head_sha+type:pr" | jq -r '.items[0].user.login') + echo "pr_url=$pr_url" >> $GITHUB_OUTPUT + echo "pr_user=$pr_user" >> $GITHUB_OUTPUT + + - name: echo PR_URL and PR_USER + run: | + echo "${{ steps.get_pr_url_user.outputs.pr_url }}" + echo "${{ steps.get_pr_url_user.outputs.pr_user }}" + - name: Repository Dispatch uses: peter-evans/repository-dispatch@v2 with: @@ -42,6 +72,8 @@ jobs: { "repo": { "name": "${{ steps.extract_repo_name.outputs.repo_name }}", - "branch": "${{ steps.extract_branch.outputs.branch }}" + "branch": "${{ steps.extract_branch.outputs.branch }}", + "pr_url": "${{ steps.get_pr_url_user.outputs.pr_url }}", + "pr_user": "${{ steps.get_pr_url_user.outputs.pr_user }}" } }