Skip to content

Instantly share code, notes, and snippets.

@therightstuff
Last active September 6, 2022 06:19
Show Gist options
  • Save therightstuff/212d13348d76de2525f4511154fa06e0 to your computer and use it in GitHub Desktop.
Save therightstuff/212d13348d76de2525f4511154fa06e0 to your computer and use it in GitHub Desktop.
Manual trigger workflow for CircleCI
version: 2.1
parameters:
my_trigger_parameter:
type: string
default: ""
workflows:
# Workflow triggered by API call / hitting "Trigger Pipeline" in the web interface
api-triggered-workflow:
when: << pipeline.parameters.my_trigger_parameter >>
jobs:
- do-the-thing:
my_job_param: << pipeline.parameters.my_trigger_parameter >>
# Workflow triggered only by pushing a commit to the repository
commit-triggered-workflow:
when:
not: << pipeline.parameters.my_trigger_parameter >>
jobs:
- do-the-thing
jobs:
do-the-thing:
parameters:
my_job_param:
type: string
default: "triggered by commit"
steps:
- run: echo << parameters.my_job_param >>
curl --location --request POST 'https://circleci.com/api/v2/project/<org slug>/<project slug>/pipeline' \
--header 'Circle-Token: <YOUR CIRCLECI API TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"branch": "my-branch-name",
"parameters": {
"my_trigger_parameter": "triggered by API"
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment