Posts a message to Slack.
- name: Post to Slack
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: "Started a new build 🏃♀️"
op-slack-token-reference: op://My Vault/My Slack Token/tokenThe action will automatically add the following details to the Slack message:
- Workflow name
- Runner name
- Branch name
- GitHub username of the person who started the job
- Link to view the logs produced by the workflow
The details above can be omitted by setting the add-workflow-info-fields and add-view-logs-button inputs to false.
- name: Post to Slack
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: "Started a new build 🏃♀️"
op-slack-token-reference: op://My Vault/My Slack Token/token
add-workflow-info-fields: false
add-view-logs-button: falseIf you wish to only post to Slack if the jobs fails you can use the failure() status check function:
- name: Post Slack message on failure
if: ${{ failure() }}
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: "Failed building project 💥"
op-slack-token-reference: op://My Vault/My Slack Token/tokenSimilarly, you can have the action only post a message on success using the success() status check function:
- name: Post Slack message on success
if: ${{ success() }}
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: "Successfully built project 🚀"
op-slack-token-reference: op://My Vault/My Slack Token/tokenCustom fields and buttons can be added to the message as shown below. The fields and buttons must be JSON encoded as GitHub Actions inputs do not support arrays.
- name: Post to Slack
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: Hello world!
fields: '[{"title": "Foo", "value": "Bar"}]'
buttons: '[{"title": "Open Website", "url": "https://example.com"}]'
op-slack-token-reference: op://GitHub Actions/Slack Token/tokenYou may use the Slack token residing in the shared GitHub Actions vault to post messages.
- name: Post to Slack
uses: shapehq/actions/post-slack-message@v1
with:
channel: "#my-channel"
message: "Hello world!"
op-slack-token-reference: op://GitHub Actions/Slack Token/token