跳到主要内容

Manually Triggering a Pipeline

Use Case: When you need to actively execute the pipeline in non-automatic scenarios — for example, debugging a branch, verifying temporary parameters, or releasing a specific version — you can manually trigger it using the workflow_dispatch event.

Configuration Instructions

Define a workflow_dispatch workflow

Create or edit a workflow file in the .gitcode/workflows/ directory and add the workflow_dispatch trigger event:

# Manually Triggering a Pipeline
name: Manual Deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment target environment'
required: true
default: 'staging'
type: string
version:
description: 'Deployment version number'
required: true
type: string
dry-run:
description: 'Simulate only, no actual deployment'
required: false
type: string
default: "false"
tags:
description: 'Test tags (comma-separated)'
required: false
type: string

stages:
- name: validate
jobs:
- name: check-version
runs-on: {ubuntu-24,x64,small}
steps:
- run: echo "Deploy version ${{ inputs.version }} to ${{ inputs.environment }}"
- run: echo "Dry run mode = ${{ inputs.dry-run }}"
- name: deploy
jobs:
- name: push-to-env
runs-on: {ubuntu-24,x64,medium}
steps:
- run: make deploy ENV=${{ inputs.environment }} VERSION=${{ inputs.version }}

Detailed Explanation of the Inputs Field

AtomGit Action's inputs only supports string type parameters. All input values are strings.

typeDescriptionExample
stringText inputVersion number, image name, environment name

Each input field property:

  • description: Description of the input item, displayed in the trigger form.
  • required: Whether it is required (true/false).
  • default: Default value.
  • type: Input type, currently only string is supported.

Triggering the Workflow

  1. Go to the Actions tab of the project.
  2. Select the target workflow name on the left.
  3. Click the Run workflow button on the right.
  4. A form appears, select or fill in each inputs parameter, and choose the target branch.
  5. Click Run to submit the trigger.

Note: Only workflows that include workflow_dispatch in the on field will display the Run workflow button.

Referencing Inputs in the Workflow

steps:
- run: echo "Environment = ${{ inputs.environment }}"
- run: echo "Version = ${{ inputs.version }}"
- if: ${{ inputs.dry-run == 'true' }}
run: echo "This is a dry run"

The inputs context is only available in runs triggered by workflow_dispatch, referencing inputs in other trigger events will result in an error.

Frequently Asked Questions

Q: After clicking Run workflow, it prompts "This workflow does not support manual triggering"?

A: The on field of the workflow does not include the workflow_dispatch event. Please modify the .gitcode/workflows/{file}.yml file to add this trigger type.

Q: Can workflow_dispatch coexist with other trigger events?

A: Yes. The on field supports multiple events:

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
environment:
type: string

Q: How to specify a branch when manually triggering?

A: There is a branch selection dropdown in the trigger form. By default, it is set to the repository's default branch, but you can switch to any branch. The workflow will use the version of the .gitcode/workflows/ file on that branch to execute.