Skip to content

Commit 701508b

Browse files
authored
Merge pull request #28 from Erikhu1/main
dynamic workflow triggers
2 parents cf5211c + 09f264e commit 701508b

1 file changed

Lines changed: 12 additions & 26 deletions

File tree

.github/workflows/parent-workflow.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Parent Workflow
33
on: [pull_request]
44

55
permissions:
6-
contents: write
6+
contents: write
77
pages: write
88
pull-requests: write
99
id-token: write
@@ -16,31 +16,20 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19-
- name: Trigger "Check Amalgamation" Workflow
19+
- name: Define Workflows to Trigger
20+
id: define-workflows
2021
run: |
21-
echo "Triggering Check Amalgamation workflow with branch: ${{ github.head_ref }}"
22-
gh workflow run "Check amalgamation" --ref ${{ github.head_ref }} -F PARENT_SHA=${{ github.sha }}
23-
env:
24-
GH_TOKEN: ${{ secrets.PARENT_WORKFLOW_TRIGGER }}
25-
26-
- name: Trigger "Test Trudag Extensions" Workflow
27-
run: |
28-
echo "Triggering Test Trudag Extensions workflow with branch: ${{ github.head_ref }}"
29-
gh workflow run "Test Trudag extensions" --ref ${{ github.head_ref }} -F PARENT_SHA=${{ github.sha }}
30-
env:
31-
GH_TOKEN: ${{ secrets.PARENT_WORKFLOW_TRIGGER }}
32-
33-
- name: Trigger "CIFuzz" Workflow
34-
run: |
35-
echo "Triggering cifuzz workflow with branch: ${{ github.head_ref }}"
36-
gh workflow run "CIFuzz" --ref ${{ github.head_ref }} -F PARENT_SHA=${{ github.sha }}
37-
env:
38-
GH_TOKEN: ${{ secrets.PARENT_WORKFLOW_TRIGGER }}
22+
echo "CHECK_AMALGAMATION=Check amalgamation" >> workflows_list.txt
23+
echo "TEST_TRUDAG_EXTENSIONS=Test Trudag extensions" >> workflows_list.txt
24+
echo "CIFUZZ=CIFuzz" >> workflows_list.txt
25+
echo "PR_LABELER=Pull Request Labeler" >> workflows_list.txt
3926
40-
- name: Trigger "Pull Request Labeler" Workflow
27+
- name: Trigger Workflows Dynamically
4128
run: |
42-
echo "Triggering Pull Request Labeler workflow with branch: ${{ github.head_ref }}"
43-
gh workflow run "Pull Request Labeler" --ref ${{ github.head_ref }} -F PARENT_SHA=${{ github.sha }}
29+
while IFS='=' read -r ID WORKFLOW; do
30+
echo "Triggering $WORKFLOW workflow with branch: ${{ github.head_ref }}"
31+
gh workflow run "$WORKFLOW" --ref "${{ github.head_ref }}" -F PARENT_SHA="${{ github.sha }}"
32+
done < workflows_list.txt
4433
env:
4534
GH_TOKEN: ${{ secrets.PARENT_WORKFLOW_TRIGGER }}
4635

@@ -61,19 +50,16 @@ jobs:
6150
MAX_RETRIES=60 # Retry up to 60 times (15 mins, with 15s intervals)
6251
RETRY_COUNT=0
6352
64-
# Create a directory for each artifact to prevent name conflicts
6553
while [ "$COMPLETED" = "false" ] && [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
6654
COMPLETED=true
6755
6856
for ARTIFACT in "${REQUIRED_ARTIFACTS[@]}"; do
6957
echo "Attempting to download artifact: $ARTIFACT"
7058
71-
# Create a fresh directory for the artifact
7259
EXTRACT_DIR="artifacts/$ARTIFACT"
7360
rm -rf "$EXTRACT_DIR" # Ensure the directory is clean
7461
mkdir -p "$EXTRACT_DIR"
7562
76-
# Download and extract the artifact into the clean directory
7763
gh run download --name "$ARTIFACT" --dir "$EXTRACT_DIR" || COMPLETED=false
7864
done
7965

0 commit comments

Comments
 (0)