Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS_TOOK and AS_JOB return undefined/not found when running via matrix #136

Closed
nautilytics opened this issue Apr 14, 2021 · 1 comment
Closed

Comments

@nautilytics
Copy link

Describe the bug

Similar to #135, I am trying to send a Slack message and am including process.env.AS_TOOK in the custom_payload. In the below example, in Slack, I am seeing that not only is the AS_TOOK variable not found, but also AS_JOB is not found.

I followed the instructions to set things up for MATRIX_CONTEXT: ${{ toJson(matrix) }}, but I'm not sure it is working properly.

To Reproduce

name: E2E Tests and Checks

on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node: [ 14.15.5 ]

    name: E2E on Node v${{ matrix.node }}
    steps:
      - name: Send message to Slack
        uses: 8398a7/[email protected]
        with:
          icon_emoji: ':react:'
          status: custom
          fields: workflow,job,commit,repo,ref,author,took
          custom_payload: |
            {
              attachments: [{
                color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
                text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} ${{ job.status }} in ${process.env.AS_TOOK}`,
              }]
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
          MATRIX_CONTEXT: ${{ toJson(matrix) }}
        if: always()

Output in Slack

E2E Tests and Checks
Job is not found.
Check the matrix or job name. 
(438f0ad4) of <repo>@refs/heads/<branch>/gh-action-slack-notification 
by Chris<email_address> success in undefined

Expected behavior

I expected the job to be found and outputted in the custom_payload and the amount of time taken to be n seconds.

@8398a7
Copy link
Owner

8398a7 commented Jul 23, 2021

If name is changed when using matrix, it will not work.
This specification will be described in the documentation.

I have also created an issue for it to work.
If there is further discussion, please do so here.
refs: #150

@8398a7 8398a7 closed this as completed Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants