Contexts
Introduces the definitions of available contexts in the AtomGit Pipeline workflow, including available properties, access methods, and usage examples.
2.1 Available Contexts
| Context Name | Type | Description |
|---|---|---|
atomgit | object | Information about the workflow run. For more information, see atomgit. |
env | object | Variables set within a workflow, job, or step. For more information, see env. |
vars | object | Variables set at the repository, organization, or environment level. For more information, see vars. |
job | object | Information about the currently running job. For more information, see job. |
jobs | object | Reusable workflow only. Contains outputs from jobs in reusable workflows. For more information, see jobs. |
steps | object | Information about steps that ran in the current job. For more information, see steps. |
runner | object | Information about the runner executing the current job. For more information, see runner. |
secrets | object | Names and values of secrets available to the workflow run. For more information, see secret. |
strategy | object | Information about the matrix strategy used for the current job. For more information, see strategy. |
matrix | object | Attributes related to the matrix configured in the workflow that applies to the current job. For more information, see matrix. |
inputs | object | Input properties passed to an action, reusable workflow, or manually triggered workflow. For more information, see inputs. |
As part of an expression, you can access context information using one of the following two syntaxes:
- Index syntax:
atomgit['sha'] - Property dereferencing syntax:
atomgit.shaTo use the property dereferencing syntax, the property name must start with a letter or_and can only contain alphanumeric characters,-, or_.
If you try to reference an attribute that does not exist, it will evaluate to an empty string.
Determining When to Use Contexts
- Default environment variables: These environment variables only exist on the runner executing your job.
- Contexts: You can use most contexts at any time throughout the workflow, even when default variables are unavailable. For example, you can use contexts with expressions to perform initial processing before tasks are routed to a runner for execution; this allows you to use contexts associated with the conditional
ifkeyword to determine whether a step should run. Once a job starts running, you can also retrieve context variables from the runner where it executes, such asrunner.os. The following example demonstrates how to use these different types of variables together in a job:
name: CI
on:
push:
branches: main
jobs:
prod-check:
if: ${{ atomgit.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Run echo
run: echo "Deploying to production server on branch $ATOMGIT_REF"
In this example, the if statement checks the atomgit context to determine the current branch name; if the name is refs/heads/main, the subsequent steps execute. The if check is processed by AtomGit Pipeline, and the task is only sent to the runner for execution if the result is true. Once the task is sent to the runner, the steps execute and reference the variables.
Context Availability
Different contexts become available at different times during the workflow run. For example, the secrets context may only be usable in specific locations within a job.
Additionally, some functions may only be available in certain locations. For example, the hashFiles function is not available everywhere.
The table below lists usage limitations for each context and special function in the workflow. Contexts listed are only available for the given workflow key and cannot be used elsewhere. Functions can be used anywhere unless listed below.
| Workflow Scenario | Available Contexts | Special Functions |
|---|---|---|
run-name | atomgit, inputs, vars | None |
concurrency | atomgit, inputs, vars | None |
env | atomgit, secrets, inputs, vars | None |
jobs.<job_id>.concurrency | atomgit, strategy, matrix, inputs, vars | None |
jobs.<job_id>.container | atomgit, strategy, matrix, vars, inputs | None |
jobs.<job_id>.container.credentials | atomgit, strategy, matrix, env, vars, secrets, inputs | None |
jobs.<job_id>.container.env.<env_id> | atomgit, strategy, matrix, job, runner, env, vars, secrets, inputs | None |
jobs.<job_id>.container.image | atomgit, strategy, matrix, vars, inputs | None |
jobs.<job_id>.continue-on-error | atomgit, strategy, vars, matrix, inputs | None |
jobs.<job_id>.defaults.run | atomgit, strategy, matrix, env, vars, inputs | None |
jobs.<job_id>.env | atomgit, strategy, matrix, vars, secrets, inputs | None |
jobs.<job_id>.if | atomgit, vars, inputs | always, cancelled, success, failure |
jobs.<job_id>.name | atomgit, strategy, matrix, vars, inputs | None |
jobs.<job_id>.outputs.<output_id> | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | None |
jobs.<job_id>.runs-on | atomgit, strategy, matrix, vars, inputs | None |
jobs.<job_id>.secrets.<secrets_id> | atomgit, strategy, matrix, secrets, inputs, vars | None |
jobs.<job_id>.steps.continue-on-error | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.env | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.if | atomgit, strategy, matrix, job, runner, env, vars, steps, inputs | always, cancelled, success, failure, hashFiles |
jobs.<job_id>.steps.name | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.run | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.timeout-minutes | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.with | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.steps.working-directory | atomgit, strategy, matrix, job, runner, env, vars, secrets, steps, inputs | hashFiles |
jobs.<job_id>.strategy | atomgit, vars, inputs | None |
jobs.<job_id>.timeout-minutes | atomgit, strategy, matrix, vars, inputs | None |
jobs.<job_id>.with.<with_id> | atomgit, strategy, matrix, inputs, vars | None |
on.workflow_call.inputs.<inputs_id>.default | atomgit, inputs, vars | None |
on.workflow_call.outputs.<output_id>.value | atomgit, jobs, vars, inputs | None |
Example: Printing Context Information to Logs
You can print the contents of contexts to the log for debugging purposes. toJson is required to pretty-print JSON objects to the log.
[!WARNING] When using the entire
atomgitcontext, be aware that it contains sensitive information such asatomgit.token. AtomGit Pipeline masks keys when printing them to the console, but you should exercise caution when exporting or printing contexts.
name: Context testing
on:
push:
branches: main
jobs:
dump_contexts_to_log:
runs-on: ubuntu-latest
steps:
- name: Dump Atomgit context
env:
ATOMGIT_CONTEXT: ${{ toJson(atomgit) }}
run: echo "$ATOMGIT_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
2.2 atomgit Context
The atomgit context contains information about the workflow run and the event that triggered it. You can read most atomgit context data in environment variables.
[!WARNING] When using the entire
atomgitcontext, be aware that it contains sensitive information such asatomgit.token. AtomGit Pipeline masks keys when printing them to the console, but you should exercise caution when exporting or printing contexts. [!WARNING] When creating workflows and actions, you should always consider whether your code might execute untrusted input from potential attackers. Some contexts should be treated as untrusted input because attackers could insert malicious content.
| Attribute Name | Type | Description |
|---|---|---|
atomgit | object | Top-level context available during any job or step in the workflow. This object contains all attributes listed below. |
atomgit.action | string | The name of the currently running action, or step's . AtomGit Pipeline removes special characters, and when the current step runs a script without an id, it uses the name __run. If the same action is used multiple times in the same job, the name will include an underscore sequence suffix. For example, the first script you run will be named __run, and the second will be named __run_2. Similarly, the second call to actions/checkoutwould beactionscheckout2`. |
atomgit.action_path | string | The path where the action resides. This attribute is only supported in composite actions. You can use this path to access files in the same repository as the action, for example by changing directory to the path: cd ${{ atomgit.action_path }}. |
atomgit.action_ref | string | For steps executing an action, this is the reference of the action being executed. For example, v2. Do not use in run keywords. To make this context work with composite actions, reference it in the composite action's env context. |
atomgit.action_repository | string | For steps executing an action, this is the owner and repository name of the action. For example, actions/checkout. Do not use in run keywords. To make this context work with composite actions, reference it in the composite action's env context. |
atomgit.actor | string | The username of the user who triggered the initial workflow run. If the workflow run is a rerun, this value may differ from atomgit.triggering_actor. Any workflow rerun will use the permissions of atomgit.actor, even if the initiator of the rerun (atomgit.triggering_actor) has different permissions. |
atomgit.actor_id | string | The account ID of the person or application that triggered the initial workflow run. For example, 1234567. Note that this differs from the actor username. |
atomgit.api_url | string | The URL of the AtomGit REST API. |
atomgit.base_ref | string | The base_ref or target branch of the pull request in the workflow run. This attribute is only available when the event triggering the workflow run is pull_request or pull_request_target. |
atomgit.env | string | The path to the file on the runner where environment variables are set from workflow commands. This file is unique to the current step, and each step in the job uses a different file. |
atomgit.event | object | The complete event webhook payload. You can use this context to access individual attributes of the event. This object is identical to the webhook payload of the event that triggered the workflow run and varies for each event. Links to webhooks for each AtomGit Pipeline event are in . For example, for a workflow run triggered by , this object contains the contents of . |
atomgit.event_name | string | The name of the event that triggered the workflow run. Includes Push, MR, Note, IssueComment, Scheduler. |
atomgit.event_path | string | The path to the file on the runner containing the complete event webhook payload. |
atomgit.head_ref | string | The head_ref or source branch of the pull request in the workflow run. This attribute is only available when the event triggering the workflow run is pull_request or pull_request_target. |
atomgit.job | string | The for the current job. Note: This context attribute is set by the Actions execution environment and is only available in the execution steps of a job. Otherwise, the value of this attribute is null. |
atomgit.path | string | The path to the file on the runner where the system PATH variable is set from workflow commands. This file is unique to the current step, and each step in the job uses a different file. |
atomgit.ref | string | The full reference of the branch or tag that triggered the workflow run. For push-triggered workflows, this is the pushed branch or tag reference. For unmerged pull_request-triggered workflows, this is the pull request merge branch. If the pull request is merged, this is the main branch. For release-triggered workflows, this is the created release tag. For other triggers, this is the branch or tag reference that triggered the workflow run. This reference is only set if there is an available branch or tag for the event type. The given reference is complete, meaning for branches, the format is refs/heads/<branch_name>. For unmerged pull request events except pull_request_target, it is refs/pull/<pr_number>/merge. pull_request_target events have a ref from the base branch. For tags, it is refs/tags/<tag_name>. For example, refs/heads/feature-branch-1. |
atomgit.ref_name | string | The short reference name of the branch or tag that triggered the workflow run. This value matches the branch or tag name displayed on AtomGit. For example, feature-branch-1. For unmerged pull requests, the format is <pr_number>/merge. |
atomgit.ref_type | string | The type of reference that triggered the workflow run. Valid values are branch or tag. |
atomgit.repository | string | Owner and repository name. For example, octocat/Hello-World. |
atomgit.repository_id | string | The ID of the repository. For example, 123456789. Note that this differs from the repository name. |
atomgit. | string | The Git URL of the repository. For example, git://atomgit.com/octocat/hello-world.git. |
atomgit.retention_days | string | The number of days to retain workflow run logs and artifacts. |
atomgit.run_id | string | A unique number for each workflow run in the repository. This number does not change if you rerun the workflow run. |
atomgit.run_number | string | A unique number for each run of a specific workflow in the repository. This number starts at 1 for the first run of the workflow and increments with each new run. This number does not change if you rerun the workflow run. |
atomgit.run_attempt | string | A unique number for each attempt of a specific workflow run in the repository. This number starts at 1 for the first attempt of the workflow run and increments with each rerun. |
atomgit.server_url | string | The URL of the AtomGit server. For example: https://atomgit.com. |
atomgit.sha | string | The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For example, ffac537e6cbbf934b08745a378932722df287a53. |
atomgit.token | string | The token used to authenticate as the AtomGit App installed in your repository. This is functionally equivalent to the ATOMGIT_TOKEN secret. Note: This context attribute is set by the Actions execution environment and is only available in the execution steps of a job. Otherwise, the value of this attribute is null. |
atomgit.triggering_actor | string | The username of the user who initiated the workflow run. If the workflow run is a rerun, this value may differ from atomgit.actor. Any workflow rerun will use the permissions of atomgit.actor, even if the initiator of the rerun (atomgit.triggering_actor) has different permissions. |
atomgit.workflow | string | The name of the workflow. If the workflow file does not specify a name, the value of this attribute is the full path of the workflow file in the repository. |
atomgit.workflow_ref | string | The reference path of the workflow. For example, octocat/hello-world/.atomgit/workflows/my-workflow.yml@refs/heads/my_branch. |
atomgit.workflow_sha | string | The commit SHA of the workflow file. |
atomgit.workspace | string | The default working directory for steps on the runner, as well as the default location of your repository when using the action. |
atomgit.start_timestamp | string | The timestamp when the workflow started. |
2.3 atomgit.event
Overview
atomgit.event is a sub-object under the atomgit context that carries the event payload that triggered the current workflow run. When an event triggers a workflow, the platform mounts the complete payload of that event directly under atomgit.event for the workflow to read via expressions.
atomgit.event is 100% isomorphic to the event's Webhook payload: field names, nesting levels, and value meanings are completely identical. Therefore, the payload structure you see in the Webhook documentation can be accessed directly in the workflow in the form of atomgit.event.<field_path>. For example, comment.body in the payload becomes atomgit.event.comment.body in the workflow.
Fields mounted under atomgit.event vary depending on the triggering event. All events share a set of common base fields (action, sender, repository, etc.), and each event appends its own proprietary fields. This section explains them by event scenario.
Note
atomgit.event.actionrepresents the event's activity type (e.g.,created,edited), which is not the same field as the top-level contextatomgit.action(current step identifier); do not confuse them.- Fields marked "only
xxx" only appear under corresponding activity types and will return empty values when read under other activity types. - Fields like
head_commit,merged_at,review.bodymay benullunder specific conditions; it is recommended to check for null before use. - The "Value" column of tables annotates the complete set of enumerated values for enum-type fields; fields not annotated accept free-form values.
Common Base Fields (Shared by All Events)
The following fields exist in atomgit.event for all events and will not be repeated in subsequent scenarios.
| Access Path | Type | Value | Description |
|---|---|---|---|
atomgit.event.action | string | Depends on the event, see scenarios | Event activity type; push events do not have this field. Commonly used to distinguish actions in if conditions |
atomgit.event.sender.id | integer | — | User ID that triggered the event |
atomgit.event.sender.login | string | — | Initiator login name, used to identify who triggered the run |
atomgit.event.repository.id | integer | — | Repository ID |
atomgit.event.repository.name | string | — | Repository name |
atomgit.event.repository.full_name | string | — | Full repository name (owner/repo), commonly used when constructing API addresses |
atomgit.event.repository.default_branch | string | — | Repository default branch name |
atomgit.event.repository.private | boolean | true / false | Whether it is a private repository, affects Fork and credential policies |
Event Correspondence to atomgit.event_name
| Event Type | atomgit.event_name Value |
|---|---|
workflow_dispatch | Manual |
workflow_call | Follows the main workflow's event_name |
push | Push |
pull_request | MR |
pull_request | MR |
pull_request_target | MR |
pull_request_comment | Note |
issue_comment | IssueComment |
schedule | Scheduler |
push Event
Triggered upon code push. This event has no action field; the payload focuses on references and commit information for the current push.
| Access Path | Type | Value | Description |
|---|---|---|---|
atomgit.event.ref | string | — | Full reference pushed, e.g., refs/heads/main, commonly used as a branch filter basis |
atomgit.event.before | string | — | Commit SHA pointed to by the reference before push; all zeros for new branches |
atomgit.event.after | string | — | Commit SHA pointed to by the reference after push; |
atomgit.event.created | boolean | true / false | Whether this push creates a new reference |
atomgit.event.base_ref | string | — | Reference source for new branch creation, otherwise null |
atomgit.event.head_commit.id | string | — | SHA of the latest commit after push; null for deleted branches |
atomgit.event.head_commit.message | string | — | Message of the latest commit after push |