Skip to content

Commit f27ff0e

Browse files
committed
ci: report test status to changes made from forks
1 parent b76e933 commit f27ff0e

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.circleci/config.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,23 @@ jobs:
386386
command: |
387387
# TODO: once CircleCI updates its pipeline-invocation API, move off of Cheng's personal CircleCI access token, which is saved to both of the slackapi CircleCI "contexts" as an env var:
388388
# https://app.circleci.com/settings/organization/github/slackapi/contexts
389+
if [[ -z "$CIRCLE_BRANCH" || "$CIRCLE_BRANCH" == pull/* ]]; then
390+
BRANCH_NAME="main"
391+
else
392+
BRANCH_NAME="$CIRCLE_BRANCH"
393+
fi
389394
TEST_JOB_WORKFLOW_ID=$(curl --location --request POST 'https://circleci.com/api/v2/project/gh/slackapi/platform-devxp-test/pipeline' \
390395
--header 'Content-Type: application/json' \
391396
-u "${CCHEN_CIRCLECI_PERSONAL_TOKEN}:" \
392-
--data "{\"branch\":\"${CIRCLE_BRANCH}\",\"parameters\":{\"slack_cli_build_tag\":\"${RELEASE_REF}\"}}" | jq '.id')
397+
--data "{\"branch\":\"${BRANCH_NAME}\",\"parameters\":{\"slack_cli_build_tag\":\"${RELEASE_REF}\"}}" | jq '.id')
393398
if [ $TEST_JOB_WORKFLOW_ID = "null" ]; then
394399
echo "Performing the standard test suite found on the \"main\" branch of the end-to-end tests"
395400
TEST_JOB_WORKFLOW_ID=$(curl --location --request POST 'https://circleci.com/api/v2/project/gh/slackapi/platform-devxp-test/pipeline' \
396401
--header 'Content-Type: application/json' \
397402
-u "${CCHEN_CIRCLECI_PERSONAL_TOKEN}:" \
398403
--data "{\"branch\":\"main\",\"parameters\":{\"slack_cli_build_tag\":\"${RELEASE_REF}\"}}" | jq '.id')
399404
else
400-
echo "Performing the changed tests on the \"$CIRCLE_BRANCH\" branch of the end-to-end tests"
405+
echo "Performing the changed tests on the \"$BRANCH_NAME\" branch of the end-to-end tests"
401406
fi
402407
if [ $TEST_JOB_WORKFLOW_ID = "null" ]; then
403408
echo "Failed to start the testing workflow"

.github/workflows/e2e_tests.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@ on:
55
workflow_dispatch:
66
inputs:
77
branch:
8-
description: 'The branch to build'
8+
description: "The branch to build"
9+
required: true
10+
status:
11+
description: "Report test status"
12+
default: false
13+
type: boolean
914
required: true
1015

1116
jobs:
1217
execute:
18+
name: Start tests
1319
runs-on: ubuntu-latest
1420
steps:
15-
- name: Trigger CircleCI build-beta workflow.
21+
- name: Trigger CircleCI 'local' workflow
22+
if: ${{ github.event.inputs.status == 'false' }}
23+
uses: promiseofcake/circleci-trigger-action@v1
24+
with:
25+
user-token: ${{ secrets.CIRCLECI_TOKEN }}
26+
project-slug: slackapi/slack-cli
27+
branch: ${{ github.event.inputs.branch }}
28+
payload: '{"run_local_build_test_workflow": true}'
29+
- name: Trigger CircleCI 'e2e' workflow
30+
if: ${{ github.event.inputs.status == 'true' }}
1631
uses: promiseofcake/circleci-trigger-action@v1
1732
with:
1833
user-token: ${{ secrets.CIRCLECI_TOKEN }}
1934
project-slug: slackapi/slack-cli
2035
branch: ${{ github.event.inputs.branch }}
21-
payload: '{"run_local_build_test_workflow": true}'
36+
payload: '{"run_local_build_test_workflow": false}'

0 commit comments

Comments
 (0)