Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

get action job id

v1.6

get action job id

play

get action job id

get action job id

Installation

Copy and paste the following snippet into your .yml file.

              

- name: get action job id

uses: ayachensiyuan/[email protected]

Learn more about this action in ayachensiyuan/get-action-job-id

Choose a version

Get github action current job id


GitHub official has not provide access to the job id by using existing API.

This tool could help you to get job id easier.

Usage


Pre-requisites

Create a workflow *.yml file in your repositories .github/workflows directory.

Example-1 Get a single job id

jobs:
  get-job-id: 
    runs-on: ubuntu-latest
    name: 'SET-A-NEW-NAME' # change SET-A-NEW-NAME
    steps:
    - name: set id
      id: set-job-id
      uses: ayachensiyuan/get-action-job-id@main
      env: 
    	  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        job-name: 'SET-A-NEW-NAME' # must be the same as 'get-job-id.name' 

    # get id     
    - name: get id
      run: echo "The current job id is ${{ steps.set-job-id.outputs.jobId }}"

Example-2 Get bulk of job-ids

jobs:
  get-job-id: 
    runs-on: ubuntu-latest
    strategy:
      matrix:
        cases: ['case1', 'case2', 'case3', 'case4'] # matrix cases
    name: ${{ matrix.cases }} 
    steps:
    - name: set id
      id: set-job-id
      uses: ayachensiyuan/get-action-job-id@main
      env: 
    	  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        job-name: ${{ matrix.cases }} # must be the same as 'get-job-id.name' 

    # get id     
    - name: get id
      run: echo "The current job id is ${{ steps.set-job-id.outputs.jobId }}"

⚠️ Make sure 'name' field value must be the same as 'job-name' field value. And name must be unique name.

License


The scripts and documentation in this project are released under the MIT License.