跳到主要内容

Workflow File Location and Basic Structure

This document introduces the directory where AtomGit Action workflow files are stored, naming conventions, YAML structure fields, and configuration items such as stages, post, concurrency, and permissions.

When you need to create your first AtomGit Action pipeline in a repository or want to know where the workflow file should be placed, how to name it, and what the basic YAML structure looks like.

Prerequisites

  • A existing AtomGit repository with write access.
  • The AtomGit Action feature is enabled.
  • The repository can use a managed Runner or has a self-hosted Runner 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 Description

File Storage Directory

The directory for storing AtomGit Action workflow files is:

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

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

Naming Suggestions

ScenarioRecommended FilenameDescription
Continuous Integrationci.ymlBuild and test on push or PR
Pull Request Checkpr-check.ymlAutomatic check on PR submission
Releaserelease.ymlTrigger release process on Tag
Docker Image Builddocker-build.ymlBuild and push image
Scheduled Tasknightly.ymlDaily scheduled build
Manual Deploymentdeploy.ymlManual trigger deployment

Basic Structure Fields

A minimal workflow file includes the following core fields:

FieldRequiredDescription
nameNoDisplay name of the workflow, defaults to the filename if not specified
onYesTrigger condition, defines which events trigger the workflow
envNoWorkflow-level environment variables, visible to all jobs and steps
defaultsNoDefault settings, such as default shell and working directory
concurrencyNoConcurrency control, limits the number of parallel runs for the same workflow
permissionsNoPermission declaration, controls the scope of the ATOMGIT_TOKEN
stagesNoStage definition, configured only when stage serial control is needed
jobsYesTask collection (top-level field when no stages are present, nested within stages when stages are present)
postNoPost-processing stage, used for notifications, cleanup, and writing back data

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

  • Serial Execution Between Stages: Multiple stages are executed in the order defined, and the next stage starts only after all jobs in the previous stage are completed.
  • fail_fast: When a job in a stage fails, you can configure whether to immediately terminate the execution of subsequent stages.
  • Optional: When a workflow has only one stage, the stages field can be omitted. In this case, all jobs are executed 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 unittest
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: Deployment Stage
jobs:
deploy:
name: Deployment
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run deploy
run: echo "deploy"

post Post-Processing Stage

post is a unique post-processing stage in AtomGit Action, used for notifications, resource cleanup, and status writing after the workflow execution.

  • Suitable for placing logic such as notification pushing (e.g., email, IM messages), temporary file cleanup, and result writing.
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, send 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, default is true
events: [mr_id] # Preemption events, can only configure up to 10, refer to the usage of 'on'
FieldDescription
enableWhether to enable concurrency control
maxMaximum number of concurrent runs, range 1-5
exceed-actionStrategy when exceeding the concurrency limit: IGNORE (ignore new requests) or QUEUE (queue and wait)
preemption.enableWhether to enable preemption strategy, default is true
preemption.eventsPreemption events, can only configure up to 10

Permissions

AtomGit Action's permission system, using the corresponding permission items from the atomgit context:

permissions:
project: read
pr: write
issue: read
note: write
repository: read
Permission ItemDescriptionOptional Levels
projectProject access rightsread / write / none
prPull Request rightsread / write / none
issueIssue rightsread / write / none
noteComment/Note rightsread / write / none
repositoryRepository rightsread / write / none

Shortcut syntax:

  • read-all: Set all permissions to read
  • write-all: Set all permissions to write
  • permissions: {}: Set all permissions to none (principle of least privilege)
permissions: read-all
permissions: {}

Common Questions

Q: When can the stages field be omitted?

A: When the workflow has only one logical stage (or does not require stage serial control), the stages field can be omitted. After omission, all jobs are executed in parallel by default, and dependency relationships can be configured via needs.