@@ -5,46 +5,36 @@ inputs:
5
5
run_attempt :
6
6
description : ' Run attempt number'
7
7
required : true
8
-
9
- outputs :
10
- tests_to_run :
11
- description : ' Modified tests to run based on rerun logic'
8
+ github_context :
9
+ description : ' GitHub context as a JSON string'
10
+ required : true
11
+ github_token :
12
+ description : ' GitHub Token'
13
+ required : true
12
14
13
15
runs :
14
16
using : ' composite'
15
17
steps :
16
- - name : Check if this is a re-run and modify tests_to_run
18
+ - name : Check if this is a re-run
17
19
shell : bash
18
20
run : |
19
- tests_to_run="all" # Default value
21
+ # Parse the JSON string input
22
+ github_context=$(echo "${{ inputs.github_context }}" | jq -r '.')
23
+ run_id=$(echo "$github_context" | jq -r '.run_id')
24
+ repository=$(echo "$github_context" | jq -r '.repository')
20
25
21
26
if [ "${{ inputs.run_attempt }}" -gt 1 ]; then
22
27
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 }}" \
28
+ curl -H "Authorization: token ${{ inputs.github_token }}" \
26
29
-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
30
+ "https://api.github.com/repos/$repository/actions/runs/$run_id" > run_details.json
36
31
triggering_actor=$(jq -r '.triggering_actor.login' run_details.json)
37
-
38
32
echo "Triggering Actor: $triggering_actor"
39
-
40
33
if [[ "$triggering_actor" == "gha-bstack-rerun[bot]" ]]; then
41
34
echo "The run was triggered by the GitHub App."
42
- tests_to_run="rerun_tests" # Set custom value if triggered by GitHub App
43
35
else
44
- echo "The run was triggered by: $triggering_actor "
36
+ echo "The run was triggered by: ${{ github.actor }} "
45
37
fi
46
38
else
47
39
echo "This is the first run."
48
40
fi
49
-
50
- echo "tests_to_run=${tests_to_run}" >> $GITHUB_OUTPUT
0 commit comments