Skip to content

Add redefine mode to trigger action #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ inputs:
description: 'Name of the workflow to trigger'
required: true
default: 'default'
redefine-mode:
description: 'Redefine Test Selection Mode'
default: 'PASSIVE'
circleci-token:
description: 'A personal API token to CircleCI'
required: true
runs:
using: "composite"
steps:
- run: ${{ github.action_path }}/trigger_circleci_pipeline.sh ${{ inputs.triggered-workflow }}
- run: ${{ github.action_path }}/trigger_circleci_pipeline.sh ${{ inputs.triggered-workflow }} ${{ inputs.redefine-mode }}
shell: bash
env:
CIRCLECI_USER_PERSONAL_API_TOKEN: ${{ inputs.circleci-token }}
Expand Down
9 changes: 8 additions & 1 deletion trigger_circleci_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ CIRCLE_WORKFLOW_URL_BASE="https://circleci.com/workflow-run"

branch="${BRANCH_REF#refs/heads/}"
workflow_to_trigger=$1
redefine_mode=$2
# If redefine_mode is missing or not "PASSIVE" or "ACTIVE" - set as "PASSIVE"
if [ -z "$redefine_mode" ] || [ "$redefine_mode" != "PASSIVE" ] && [ "$redefine_mode" != "ACTIVE" ]; then
echo "Missing redefine_mode or redefine_mode is not PASSIVE or ACTIVE. Setting as PASSIVE."
redefine_mode="PASSIVE"
fi

trigger_pipeline_response=$(
curl -sSX POST \
Expand All @@ -18,7 +24,8 @@ trigger_pipeline_response=$(
-d "{
\"branch\": \"${branch}\",
\"parameters\": {
\"triggered_workflow\": \"${workflow_to_trigger}\"
\"triggered_workflow\": \"${workflow_to_trigger}\",
\"redefine_mode\": \"${redefine_mode}\"
}
}" \
"${CIRCLECI_PROJECT_API_BASE}/pipeline"
Expand Down