-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shahbaz Mastan
committed
Sep 10, 2024
1 parent
1698f51
commit bbea39e
Showing
3 changed files
with
71 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: CI Workflow | ||
|
||
on: | ||
pull_request_target: | ||
types: "*" | ||
branches: "**" | ||
permissions: read-all | ||
|
||
jobs: | ||
Trigger_Workflows: | ||
runs-on: ubuntu-latest | ||
name: CI Workflow | ||
steps: | ||
- name: Get Token | ||
run: | | ||
retries=3 | ||
while [ $retries -gt 0 ]; do | ||
if RESPONSE=$(curl --silent --location "${{ secrets.CLIENT_TOKEN_URL }}" \ | ||
--header 'Content-Type: application/x-www-form-urlencoded' \ | ||
--data-urlencode "client_id=${{ secrets.CLIENT_ID }}" \ | ||
--data-urlencode "client_secret=${{ secrets.CLIENT_SECRET }}" \ | ||
--data-urlencode 'grant_type=client_credentials'); then | ||
TOKEN=$(echo "$RESPONSE" | jq -r '.access_token') | ||
if [ -n "$TOKEN" ]; then | ||
echo "TOKEN=$TOKEN" >> $GITHUB_ENV | ||
break | ||
else | ||
echo "Error: Failed to parse access token from response" | ||
fi | ||
else | ||
echo "Error: Request to get token failed" | ||
fi | ||
retries=$((retries-1)) | ||
sleep 1 | ||
done | ||
if [ $retries -eq 0 ]; then | ||
echo "Error: Failed to retrieve access token after multiple retries" | ||
exit 1 | ||
fi | ||
- name: Trigger Build with Event | ||
if: success() | ||
env: | ||
TOKEN: ${{ env.TOKEN }} | ||
run: | | ||
EVENT_DATA='${{ toJSON(github.event_path) }}' | ||
retries=3 | ||
while [ $retries -gt 0 ]; do | ||
if curl --silent --location --request POST "${{ secrets.CLIENT_PUBLISH_URL }}" \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'x-github-event: github' \ | ||
--header "Authorization: Bearer $TOKEN" \ | ||
--data "@${{ github.event_path }}"; then | ||
break | ||
else | ||
echo "Error: Failed to trigger build" | ||
fi | ||
retries=$((retries-1)) | ||
sleep 1 | ||
done | ||
if [ $retries -eq 0 ]; then | ||
echo "Error: Failed to trigger build after multiple retries" | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,4 +93,4 @@ jobs: | |
if [ $retries -eq 0 ]; then | ||
echo "Error: Failed to trigger build after multiple retries" | ||
exit 1 | ||
fi | ||
fi |
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