Skip to content

ayachensiyuan/get-action-job-id

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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/[email protected]
      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/[email protected]
      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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published