跳到主要内容

Workflow File Location and Basic Structure

This documentation outlines the directory structure, naming conventions, YAML structural fields, and configuration options such as stages, post, concurrency, and permissions for AtomGit Action workflow files.

It is useful when you need to create your first AtomGit Action pipeline in a repository, or when you want to know where workflow files should be placed, how to name them, and how to write the basic YAML structure.

Prerequisites​

  • An existing AtomGit repository with write access.
  • The AtomGit Action feature is enabled (Project Settings - Basic Settings - Actions Permission Control).
  • The repository uses the AtomGit-hosted runner pool or has self-hosted runners configured.

Quick Example​

name: ci

on:
push:
branches:
- main

jobs:
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Checkout source code
uses: checkout
- name: Run build
run: echo "build success"

Configuration Details​

File Directory​

The directory for storing workflow files for AtomGit Action is:

.gitcode/workflows/<workflow-name>.yml

Only files with the .yml or .yaml extensions are recognized as workflow files; all other extensions will be ignored.

Naming Recommendations​

ScenarioRecommended FilenameDescription
Continuous Integrationci.ymlBuilds and tests on push or PR
Pull Request Checkspr-check.ymlAutomatically checks on PR submission
Releaserelease.ymlTriggers release workflow on tag creation
Docker Image Builddocker-build.ymlBuilds and pushes Docker images
Scheduled Tasknightly.ymlRuns daily scheduled builds
Manual Deploymentdeploy.ymlManually triggered deployment

Basic Structure Fields​

A minimal workflow file includes the following core fields:

FieldRequiredDescription
nameOptionalDisplay name for the workflow. Defaults to the filename if omitted.
onYesTrigger conditions that define which events activate the workflow.
envOptionalWorkflow-level environment variables, visible to all jobs and steps.
defaultsOptionalDefault settings, such as the default shell and working-directory.
concurrencyOptionalConcurrency control to limit the number of parallel runs for the same workflow.
permissionsOptionalPermission declarations that control the scope of the ATOMGIT_TOKEN.
stagesOptionalStage definitions. Configured only when sequential stage control is required.
jobsYesJob collection (top-level field if stages is omitted, nested within stages if defined).
postOptionalPost-processing stage used for notifications, cleanup, status updates, etc.

Complete Basic Structure Example​

name: Example Pipeline

on:
push:
branches:
- main

env:
APP_NAME: my-app

defaults:
run:
shell: bash

concurrency:
enable: true
max: 3
exceed-action: QUEUE

permissions:
repository: read
pr: write

stages:
build_stage:
name: Build
jobs:
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Checkout source code
uses: checkout
- name: Run build
run: echo "build"

post:
jobs:
post-process:
name: Notification
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Send notification
run: echo "notification"

Stages Mechanism​

  • Sequential Execution Between Stages: Multiple stages execute sequentially in the order defined. The next stage begins only after all jobs in the previous stage complete.
  • fail_fast: Configurable behavior to immediately terminate subsequent stages if any job within a stage fails.
  • Optional: When a workflow consists of only one stage, the stages field can be omitted. In this case, all jobs run in parallel by default.
name: staged-pipeline

on:
push:
branches:
- main

stages:
build-stage:
name: Build Stage
fail_fast: true
jobs:
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run build
run: echo "build"

test-stage:
name: Test Stage
fail_fast: false
jobs:
unit-test:
name: Unit Test
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run unit test
run: echo "unit test"

integration-test:
name: Integration Test
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run integration test
run: echo "integration test"

deploy-stage:
name: Deploy Stage
jobs:
deploy:
name: Deploy
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run deploy
run: echo "deploy"

Post-Processing Stage​

post is a unique post-processing stage in AtomGit Action, designed for notifications, resource cleanup, status updates, and other operations after the main workflow execution completes.

  • Ideal for logic such as sending notifications (e.g., emails, IM messages), cleaning up temporary files, and writing back execution results.
name: ci-with-post

on:
push:
branches:
- main

jobs:
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run build
run: echo "build"

post:
jobs:
post-process:
name: Notification
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Send notification
run: echo "Workflow finished. Sending notification..."

Concurrency Control​

Concurrency control configuration for AtomGit Action:

concurrency:
enable: true
max: 3
exceed-action: QUEUE
preemption: # Preemption strategy
enable: true # Whether to enable, defaults to true
events: [mr_id] # Preemption events
FieldDescription
enableWhether to enable concurrency control
maxMaximum number of concurrent runs (range: 1–120)
exceed-actionStrategy when concurrency limit is exceeded: IGNORE (discard new requests) or QUEUE (wait in line)
preemption.enableWhether to enable preemption strategy (defaults to true)
preemption.eventsEvents that trigger preemption; supports mr_id

Permissions​

The permission system in AtomGit Action utilizes the following permission scopes mapped to the atomgit context:

permissions:
project: read
pr: write
issue: read
note: write
repository: read
Permission ScopeDescriptionAvailable Levels
projectProject access permissionread / write / none
prPull Request permissionread / write / none
issueIssue permissionread / write / none
noteComment/Nickname permissionread / write / none
repositoryRepository permissionread / write / none

Quick Syntax:

  • read-all: Sets all permissions to read automatically.
  • write-all: Sets all permissions to write automatically.
  • permissions: {}: Sets all permissions to none (follows the principle of least privilege).
permissions: read-all
permissions: {}

Frequently Asked Questions​

Q: When can the stages field be omitted?

A: The stages field can be omitted when the workflow consists of only one logical phase (or when sequential stage control is not needed). When omitted, all jobs run in parallel by default, and dependencies can be configured using the needs keyword.