Skip to content

Commit 5653e99

Browse files
committed
Passing all vars
1 parent 35a6dd8 commit 5653e99

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

setup-rerun-vars/action.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,36 @@ inputs:
55
run_attempt:
66
description: 'Run attempt number'
77
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
1214

1315
runs:
1416
using: 'composite'
1517
steps:
16-
- name: Check if this is a re-run and modify tests_to_run
18+
- name: Check if this is a re-run
1719
shell: bash
1820
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')
2025
2126
if [ "${{ inputs.run_attempt }}" -gt 1 ]; then
2227
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 }}" \
2629
-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
3631
triggering_actor=$(jq -r '.triggering_actor.login' run_details.json)
37-
3832
echo "Triggering Actor: $triggering_actor"
39-
4033
if [[ "$triggering_actor" == "gha-bstack-rerun[bot]" ]]; then
4134
echo "The run was triggered by the GitHub App."
42-
tests_to_run="rerun_tests" # Set custom value if triggered by GitHub App
4335
else
44-
echo "The run was triggered by: $triggering_actor"
36+
echo "The run was triggered by: ${{ github.actor }}"
4537
fi
4638
else
4739
echo "This is the first run."
4840
fi
49-
50-
echo "tests_to_run=${tests_to_run}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)