ravsamhq / notify-slack-action

🔔 Send a Slack Notification from Github Actions regarding failure, warnings, or even success.
https://ravsam.in/blog/send-slack-notification-when-github-actions-fails/
MIT License
173 stars 57 forks source link

Ability to print the "name" property of the job #36

Closed jay-cresta closed 2 years ago

jay-cresta commented 2 years ago

We have reusable job which runs on different parameters and also the name of the job is generated dynamically.

jobs:
  test:
    name: Run ${{ inputs.param1 }} tests on ${{ inputs.param2 }}
    runs-on: ubuntu-latest

With a job setup something lie this, the name always prints as "test" in the slack notification instead of the name generated at runtime

image

ravgeetdhillon commented 2 years ago

@jay-cresta The name of the job is test. You are dynamically generating the name of the step in the test job. There is no way to define a job name dynamically.

jay-cresta commented 2 years ago

@ravgeetdhillon Sorry for the confusion caused because of partial code snippet. Actually that is the name property of the job (can be called description) and is not part of the steps. See below..

jobs:
  test:
    name: Run ${{ inputs.param1 }} tests on ${{ inputs.param2 }}
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Install Dependencies 
        run: |
          npm i

      - name: Setup node 12
        uses: actions/setup-node@v1
        with:
          node-version: 12.x

Is there a way to show the name property of the job? Thanks a ton!

ravgeetdhillon commented 2 years ago

@jay-cresta I'm not sure if this is possible. You can add the following step in your workflow and dump all the data and variables in your GitHub Action workflow.

echo "${{ toJson(github) }}"

If you find something you are looking for, you can use that property directly by doing:

${{ github.job.prop1.prop2.prop3 }}

Let me know if this works for you.

ravgeetdhillon commented 2 years ago

I hope the issue is fixed as the OP reacted with the 👍 to https://github.com/ravsamhq/notify-slack-action/issues/36#issuecomment-1040186259.