Skip to content

Commit f668439

Browse files
committed
Final flow
1 parent a474edf commit f668439

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

setup-rerun-vars/action.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,43 @@ name: 'setup-rerun-vars'
22
description: 'Setup BrowserStack Rerun Variables'
33

44
inputs:
5-
run_attempt:
6-
description: 'Run attempt number'
7-
required: true
85
repository:
96
description: 'GitHub context - Repository'
107
required: true
118
run_id:
129
description: 'GitHub context - Run_ID'
1310
required: true
1411
github_token:
15-
description: 'GitHub Token'
12+
description: 'GitHub Token for authentication'
1613
required: true
1714

18-
outputs:
19-
tests_to_run:
20-
description: 'Modified tests to run based on rerun logic'
2115

2216
runs:
2317
using: 'composite'
2418
steps:
25-
- name: Check if this is a re-run
19+
- name: Set environment variables required for re-run, to be used by SDK
2620
shell: bash
2721
run: |
2822
# Assign inputs to variables
2923
run_id="${{ inputs.run_id }}"
3024
repository="${{ inputs.repository }}"
3125
github_token="${{ inputs.github_token }}"
32-
run_attempt="${{ inputs.run_attempt }}"
26+
27+
# Get the triggering actor
28+
curl -H "Authorization: token $github_token" \
29+
-H "Accept: application/vnd.github.v3+json" \
30+
"https://api.github.com/repos/$repository/actions/runs/$run_id" > run_details.json
31+
triggering_actor=$(jq -r '.triggering_actor.login' run_details.json)
32+
echo "Triggering Actor: $triggering_actor"
33+
34+
# Check if BrowserStack has triggered the re-run
35+
if [[ "$triggering_actor" == "bstack-trigger[bot]" ]]; then
36+
echo "The run was triggered by the GitHub App."
3337
34-
if [ "$run_attempt" -gt 1 ]; then
35-
echo "This run is a re-run (attempt #${run_attempt})."
36-
curl -H "Authorization: token $github_token" \
37-
-H "Accept: application/vnd.github.v3+json" \
38-
"https://api.github.com/repos/$repository/actions/runs/$run_id" > run_details.json
39-
triggering_actor=$(jq -r '.triggering_actor.login' run_details.json)
40-
echo "Triggering Actor: $triggering_actor"
41-
if [[ "$triggering_actor" == "gha-bstack-rerun[bot]" ]]; then
42-
echo "The run was triggered by the GitHub App."
43-
echo "tests_to_run=rerun_tests" >> $GITHUB_ENV
44-
else
45-
echo "The run was triggered by: ${{ github.actor }}"
46-
echo "tests_to_run=all_tests" >> $GITHUB_ENV
47-
fi
48-
else
49-
echo "This is the first run."
50-
echo "tests_to_run=all_tests" >> $GITHUB_ENV
38+
# TODO - Call BrowserStack API to get the values of the 2 environment values
39+
40+
# Set the environment variables
41+
echo "BSTACK_IS_RERUN=true" >> $GITHUB_ENV
42+
echo "BSTACK_RERUN_TESTS=test1" >> $GITHUB_ENV
5143
fi
44+

0 commit comments

Comments
 (0)