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
| Scenario | Recommended Filename | Description |
|---|---|---|
| Continuous Integration | ci.yml | Builds and tests on push or PR |
| Pull Request Checks | pr-check.yml | Automatically checks on PR submission |
| Release | release.yml | Triggers release workflow on tag creation |
| Docker Image Build | docker-build.yml | Builds and pushes Docker images |
| Scheduled Task | nightly.yml | Runs daily scheduled builds |
| Manual Deployment | deploy.yml | Manually triggered deployment |
Basic Structure Fields
A minimal workflow file includes the following core fields:
| Field | Required | Description |
|---|---|---|
name | Optional | Display name for the workflow. Defaults to the filename if omitted. |
on | Yes | Trigger conditions that define which events activate the workflow. |
env | Optional | Workflow-level environment variables, visible to all jobs and steps. |
defaults | Optional | Default settings, such as the default shell and working-directory. |
concurrency | Optional | Concurrency control to limit the number of parallel runs for the same workflow. |
permissions | Optional | Permission declarations that control the scope of the ATOMGIT_TOKEN. |
stages | Optional | Stage definitions. Configured only when sequential stage control is required. |
jobs | Yes | Job collection (top-level field if stages is omitted, nested within stages if defined). |
post | Optional | Post-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
stagesfield 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
| Field | Description |
|---|---|
enable | Whether to enable concurrency control |
max | Maximum number of concurrent runs (range: 1–120) |
exceed-action | Strategy when concurrency limit is exceeded: IGNORE (discard new requests) or QUEUE (wait in line) |
preemption.enable | Whether to enable preemption strategy (defaults to true) |
preemption.events | Events 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 Scope | Description | Available Levels |
|---|---|---|
project | Project access permission | read / write / none |
pr | Pull Request permission | read / write / none |
issue | Issue permission | read / write / none |
note | Comment/Nickname permission | read / write / none |
repository | Repository permission | read / write / none |
Quick Syntax:
read-all: Sets all permissions toreadautomatically.write-all: Sets all permissions towriteautomatically.permissions: {}: Sets all permissions tonone(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.