Charts Values Seed Trigger Dispatcher #783
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name of the Workflow | |
name: Charts Values Seed Trigger Dispatcher | |
on: | |
workflow_run: | |
workflows: | |
- "Java CI with Maven" | |
branches: | |
- master | |
- staging | |
- beta | |
types: | |
- completed | |
jobs: | |
charts-release-dispatcher: | |
name: Dispatch | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
repo: ['atlanhq/atlan'] | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
# extract branch name | |
- name: Get branch name | |
id: extract_branch | |
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.ORG_PAT_GITHUB }} | |
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.ORG_PAT_GITHUB }}" -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.ORG_PAT_GITHUB }}" -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.ORG_PAT_GITHUB }}" -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: | |
token: ${{ secrets.ORG_PAT_GITHUB }} | |
repository: ${{ matrix.repo }} | |
event-type: dispatch_chart_release_workflow | |
client-payload: |- | |
{ | |
"repo": { | |
"name": "${{ steps.extract_repo_name.outputs.repo_name }}", | |
"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 }}" | |
} | |
} |