Passing Output Parameters Between Tasks
This document introduces the three-level output passing model of AtomGit Action: Step → Job → Workflow, which supports sharing data across steps and tasks.
When you need to pass output parameters between steps, jobs, or even workflows, for example, passing the build version number from the build job to the deploy job.
Prerequisites
- Understand the roles of
id,outputs, andneeds. - Understand the usage of the
ATOMGIT_OUTPUTenvironment variable.
Quick Example
name: pipeline-with-outputs
on:
push:
branches:
- main
jobs:
prepare:
name: Prepare
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run output version
id: version
run: echo "version=1.0.0" >> "$ATOMGIT_OUTPUT"
- name: Run output sha
id: sha
run: echo "sha=${{ atomgit.sha }}" >> "$ATOMGIT_OUTPUT"
build:
name: Build
runs-on: [ubuntu-latest, x64, small]
needs: prepare
steps:
- name: Use output from prepare
run: |
echo "version=${{ jobs.prepare.outputs.version }}"
echo "sha=${{ jobs.prepare.outputs.sha }}"
Configuration Instructions
Three-Level Transmission Model
AtomGit Action supports three-level output transmission: Step → Job → Workflow
Step Output (ATOMGIT_OUTPUT)
→ Mapped to Job Output (jobs.<job_id>.outputs)
→ Mapped to Workflow_call Job Output (jobs.workflow_call_job_id.outputs)
Step Output
Write outputs in a step using the ATOMGIT_OUTPUT environment variable:
steps:
- name: Run output
id: version
run: echo "version=1.0.0" >> "$ATOMGIT_OUTPUT"
- name: Run build
id: build-result
run: |
echo "status=success" >> "$ATOMGIT_OUTPUT"
echo "artifact-path=dist/app.tar.gz" >> "$ATOMGIT_OUTPUT"
- name: Use step output
run: echo "version=${{ steps.version.outputs.version }}"
Note: The value of each output parameter cannot exceed 1MB. Use delimiter syntax for multi-line outputs.
Job Output
Map step outputs to job outputs so that other jobs can reference them via needs:
jobs:
prepare:
name: Prepare
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run output
id: version
run: echo "version=1.0.0" >> "$ATOMGIT_OUTPUT"
- name: Run build
id: build-result
run: echo "status=success" >> "$ATOMGIT_OUTPUT"
deploy:
runs-on: [ubuntu-latest, x64, small]
needs: prepare
steps:
- name: Use job output
run: |
echo "version=${{ jobs.prepare.outputs.version }}"
echo "status=${{ jobs.prepare.outputs.status }}"
Workflow Output
In a reusable workflow (workflow_call), you can map job outputs to workflow outputs:
name: reusable-build
on:
workflow_call:
outputs:
version:
description: "Build version number"
value: ${{jobs.prepare.outputs.version}}
jobs:
prepare:
name: Prepare
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Run output
id: version
run: echo "version=1.0.0" >> "$ATOMGIT_OUTPUT"
Caller receives the output:
jobs:
call-build:
name: Call build
uses: ./.gitcode/workflows/reusable-build.yml
deploy:
name: Deploy
needs: call-build
runs-on: [ubuntu-latest, x64, small]
steps:
- name: Use workflow output
run: echo "version=${{ jobs.call-build.outputs.version }}"