action-slack icon indicating copy to clipboard operation
action-slack copied to clipboard

Allow sharing common parameters between steps

Open hoxu opened this issue 3 years ago • 1 comments

Consider a workflow that has three jobs, each with a step that calls action-slack, for example:

- uses: 8398a7/action-slack@v3
  with:
    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 }}

That would be a lot of copy-paste (and potential drifting) between the jobs. As GitHub Actions does not seem to support YAML anchors, it would be nice if this action had some way of defining common options for a workflow, and then defaulting to them unless overridden.

hoxu avatar Jul 05 '21 08:07 hoxu

Thank you for your suggestion. Can you make a pull request?

8398a7 avatar Jul 23 '21 20:07 8398a7