Skip to content

Commit

Permalink
feat: Add service PRs to repository dispatch (#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
ujala-singh authored May 8, 2024
1 parent 1e819ff commit a27fdf6
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/chart-release-dispatcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}"
}
}

0 comments on commit a27fdf6

Please sign in to comment.