跳到主要内容

Context

This document is the complete reference for 12 contexts of AtomGit Action, including property definitions, JSON example content, and availability tables for each context.

AtomGit Action provides 12 contexts to access runtime environment information in workflows. Each context is a JSON object that can be accessed via expressions ${{ context.property }}.

2.1 Overview of Contexts

ContextDescriptionCommon Access Methods
atomgitAtomGit platform and event information${{ atomgit.event_name }}, ${{ atomgit.sha }}
envCustom environment variables for the current step/Job/Workflow${{ env.MY_VAR }}
varsOrganization/project-level configuration variables${{ vars.DEPLOY_ENV }}
jobCurrent Job information${{ job.status }}
jobsResults of jobs that have run in a reusable workflow${{ jobs.deploy.result }}
stepsInformation about each step in the current Job${{ steps.build.outputs.result }}
runnerRunner execution environment information${{ runner.os }}, ${{ runner.arch }}
secretsEncrypted secrets${{ secrets.DEPLOY_TOKEN }}
strategyMatrix strategy information${{ strategy.job-index }}
matrixVariable values of the current matrix instance${{ matrix.version }}
inputsInput parameters for workflow_dispatch/workflow_call${{ inputs.environment }}

2.2 Complete Properties of atomgit Context

atomgit is a core context specific to AtomGit, providing all information related to the platform and events.

PropertyTypeDescription
atomgit.event_namestringName of the current triggering event
atomgit.shastringSHA of the triggering commit
atomgit.refstringTriggered reference (full name of branch or tag, such as refs/heads/main)
atomgit.ref_namestringShort name of the triggered reference (such as main, v1.0)
atomgit.ref_typestringReference type: branch or tag
atomgit.eventobjectFull payload object of the event
atomgit.workspacestringRunner workspace path
atomgit.actionstringCurrent Action name
atomgit.tokenstringATOMGIT_TOKEN token (used for API calls)
atomgit.repositorystringRepository full name (e.g., owner/repo)
atomgit.repositoryUrlstringRepository URL
atomgit.run_idstringUnique ID of the workflow run
atomgit.run_numbernumberWorkflow run number
atomgit.run_attemptnumberNumber of workflow retries
atomgit.workflowstringWorkflow name
atomgit.head_refstringPR source branch (only for PR events)
atomgit.base_refstringPR target branch (only for PR events)
atomgit.server_urlstringRoot URL of the AtomGit platform
atomgit.api_urlstringBase URL of the AtomGit API

2.3 Event Fields of atomgit.event

push event

FieldDescription
atomgit.event.refFull ref of the push
atomgit.event.beforeSHA before the push
atomgit.event.afterSHA after the push
atomgit.event.commitsArray of commit list
atomgit.event.commits[].idSHA of a single commit
atomgit.event.commits[].messageCommit message
atomgit.event.commits[].authorCommit author
atomgit.event.commits[].addedList of added files
atomgit.event.commits[].modifiedList of modified files
atomgit.event.commits[].removedList of removed files
atomgit.event.base_refBase ref (empty for tag pushes)
atomgit.event.createdWhether it is a newly created ref
atomgit.event.deletedWhether it is a deleted ref

pull_request event

FieldDescription
atomgit.event.pull_request.numberPR number
atomgit.event.pull_request.titlePR title
atomgit.event.pull_request.bodyPR description
atomgit.event.pull_request.statePR status (open/closed)
atomgit.event.pull_request.user.loginPR creator
atomgit.event.pull_request.head.refPR source branch name
atomgit.event.pull_request.head.shaLatest SHA of the PR source branch
atomgit.event.pull_request.head.repo.full_nameFull name of the PR source repository
atomgit.event.pull_request.base.refPR target branch name
atomgit.event.pull_request.base.repo.full_nameFull name of the PR target repository
atomgit.event.pull_request.labelsList of PR labels
atomgit.event.pull_request.mergedWhether the PR has been merged
atomgit.event.pull_request.draftWhether the PR is a Draft
atomgit.event.actionPR event action type

issue_comment event

FieldDescription
atomgit.event.comment.idComment ID
atomgit.event.comment.bodyComment content
atomgit.event.comment.user.loginCommenter
atomgit.event.comment.created_atComment creation time
atomgit.event.issue.numberIssue number
atomgit.event.issue.titleIssue title
atomgit.event.issue.stateIssue status
atomgit.event.issue.pull_requestWhether it is a PR comment (exists if it is a PR)
atomgit.event.actionAction type

workflow_dispatch event

FieldDescription
atomgit.event.inputsManual trigger input parameter object

schedule event

FieldDescription
atomgit.event.scheduleList of cron expressions

2.4 Detailed Properties of Other Contexts

env Context

The env context contains variables that have been set in the workflow, job, or step. It does not include variables inherited from the execution environment process.

Example content of the env context:

{
"first_name": "Mona",
"super_duper_var": "totally_awesome"
}

Example usage of the env context:

name: Hi Mascot
on: push
env:
mascot: Mona
super_duper_var: totally_awesome
jobs:
windows_job:
name: Windows Task
runs-on: windows-latest
steps:
- run: echo 'Hi ${{ env.mascot }}' # Hi Mona
- run: echo 'Hi ${{ env.mascot }}' # Hi Octocat
env:
mascot: Octocat
linux_job:
name: Linux Task
runs-on: ubuntu-latest
env:
mascot: Tux
steps:
- run: echo 'Hi ${{ env.mascot }}' # Hi Tux

vars Context

The vars context contains custom configuration variables set at the organization, repository, and environment levels.

Example content of the vars context:

{
"mascot": "Mona"
}

Example usage of the vars context:

on:
workflow_dispatch:
env:
env_var: ${{ vars.ENV_CONTEXT_VAR }}
jobs:
display-variables:
name: ${{ vars.JOB_NAME }}
if: ${{ vars.USE_VARIABLES == 'true' }}
runs-on: ${{ vars.RUNNER }}
environment: ${{ vars.ENVIRONMENT_STAGE }}
steps:
- name: Use variables
run: |
echo "repository variable : $REPOSITORY_VAR"
echo "organization variable : $ORGANIZATION_VAR"
echo "overridden variable : $OVERRIDE_VAR"
echo "variable from shell environment : $env_var"
env:
REPOSITORY_VAR: ${{ vars.REPOSITORY_VAR }}
ORGANIZATION_VAR: ${{ vars.ORGANIZATION_VAR }}
OVERRIDE_VAR: ${{ vars.OVERRIDE_VAR }}

job Context

Example content of the job context:

{
"status": "success"
}
FieldDescription
job.statusStatus of the current Job: success, failure, cancelled
job.containerObject type, when the Job uses a custom build environment, check the environment information

steps Context

Example content of the steps context:

{
"checkout": {
"outputs": {},
"outcome": "success",
"conclusion": "success"
},
"generate_number": {
"outputs": { "random_number": "1" },
"outcome": "success",
"conclusion": "success"
}
}
PropertyDescription
steps.<step_id>.outputsStep output object
steps.<step_id>.outputs.<name>Single output value
steps.<step_id>.outcomeResult of the step completed before applying continue-on-error
steps.<step_id>.conclusionResult of the step completed after applying continue-on-error

runner Context

Example content of the runner context:

{
"os": "Linux",
"arch": "X64",
"name": "Atomgit Actions 2",
"tool_cache": "/opt/hostedtoolcache",
"temp": "/home/runner/work/_temp"
}
PropertyDescription
runner.osOperating system: Linux, Windows, macOS
runner.archArchitecture: X64, ARM, ARM64
runner.nameRunner name
runner.tempPath to the runner's temporary directory
runner.tool_cachePath to the runner's tool cache directory
runner.debugWhether debug mode is enabled

secrets Context

Example content of the secrets context:

{
"atomgit_token": "***",
"NPM_TOKEN": "***",
"SUPERSECRET": "***"
}
PropertyDescription
secrets.<NAME>Get an encrypted secret named NAME

Example usage of the secrets context:

name: Open new issue
on: workflow_dispatch
jobs:
open-issue:
name: Create Issue
runs-on: ubuntu-latest
permissions:
repository: read
issue: write
steps:
- run: |
gh issue --repo ${{ atomgit.repository }} \
create --title "Issue title" --body "Issue body"
env:
GH_TOKEN: ${{ secrets.ATOMGIT_TOKEN }}

matrix Context

{
"os": "ubuntu-latest",
"node": 16
}

Access: ${{ matrix.version }}, ${{ matrix.os }}

inputs Context

{
"build_id": "123456768",
"deploy_target": "deployment_sys_1a",
"perform_deploy": "true"
}
PropertyDescription
inputs.<name>Value of the input parameter defined in workflow_dispatch or workflow_call

2.5 Context Availability Table

Different locations have different available contexts:

ContextWorkflow LevelJob LevelStep LevelConditional Expression (if)In Action
atomgit
env
vars
job
jobs✅(caller)✅(caller)✅(caller)
steps✅(after step)✅(after current step)
runner
secrets
strategy
matrix
inputs