Skip to content

Commit 35a6dd8

Browse files
committed
Adding output
1 parent 613098a commit 35a6dd8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

setup-rerun-vars/action.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,45 @@ inputs:
66
description: 'Run attempt number'
77
required: true
88

9+
outputs:
10+
tests_to_run:
11+
description: 'Modified tests to run based on rerun logic'
12+
913
runs:
1014
using: 'composite'
1115
steps:
12-
- name: Check if this is a re-run
16+
- name: Check if this is a re-run and modify tests_to_run
1317
shell: bash
1418
run: |
19+
tests_to_run="all" # Default value
20+
1521
if [ "${{ inputs.run_attempt }}" -gt 1 ]; then
1622
echo "This run is a re-run (attempt #${{ inputs.run_attempt }})."
23+
24+
# Fetch Run Details from GitHub API
25+
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
26+
-H "Accept: application/vnd.github.v3+json" \
27+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}" > run_details.json
28+
29+
# Ensure jq is installed, install if necessary
30+
if ! command -v jq &> /dev/null; then
31+
echo "jq not found, installing..."
32+
sudo apt-get update && sudo apt-get install -y jq
33+
fi
34+
35+
# Extract triggering actor using jq
36+
triggering_actor=$(jq -r '.triggering_actor.login' run_details.json)
37+
38+
echo "Triggering Actor: $triggering_actor"
39+
40+
if [[ "$triggering_actor" == "gha-bstack-rerun[bot]" ]]; then
41+
echo "The run was triggered by the GitHub App."
42+
tests_to_run="rerun_tests" # Set custom value if triggered by GitHub App
43+
else
44+
echo "The run was triggered by: $triggering_actor"
45+
fi
1746
else
1847
echo "This is the first run."
1948
fi
2049
50+
echo "tests_to_run=${tests_to_run}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)