Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add instructions how to use status check outside if conditionals #39464

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

Merged
Sharra-writes merged 3 commits into github:main from arxeiss:patch-1
Sep 3, 2025

Conversation

Copy link
Contributor

@arxeiss arxeiss commented Jul 23, 2025

Why:

Closes: #39463

We want to send Slack message when job succeed, but also fails. And we had 2 action steps with same setup, except the message. By coincidence I have found that you can use job.status too. But it is not mentioned in the Status check functions. So I simply thought it is not possible at all.

After my finding, I was able to convert this

- name: Slack Notification Success
 if: success()
 uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 - https://github.com/slackapi/slack-github-action/releases
 with:
 token: ${{ secrets.SLACK_BOT_TOKEN }}
 method: chat.postMessage
 payload: |
 {
 "channel": "${{ secrets.SLACK_CHANNEL_FOR_DEPLOYMENT }}",
 "text": "✅ *${{ inputs.env-values-path }}:* deployed successfully",
 "thread_ts": "${{ inputs.slack_thread }}"
 }
- name: Slack Notification Failure
 if: failure()
 uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 - https://github.com/slackapi/slack-github-action/releases
 with:
 token: ${{ secrets.SLACK_BOT_TOKEN }}
 method: chat.postMessage
 payload: |
 {
 "channel": "${{ secrets.SLACK_CHANNEL_FOR_DEPLOYMENT }}",
 "text": "❌ *${{ inputs.env-values-path }}:* deployment failed. Check the pipeline ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
 "thread_ts": "${{ inputs.slack_thread }}"
 }

into

- name: Slack Notification Success
 if: success() || failure()
 uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 - https://github.com/slackapi/slack-github-action/releases
 with:
 token: ${{ secrets.SLACK_BOT_TOKEN }}
 method: chat.postMessage
 payload: |
 {
 "channel": "${{ secrets.SLACK_CHANNEL_FOR_DEPLOYMENT }}",
 "thread_ts": "${{ inputs.slack_thread }}",
 "text": "${{ job.status == 'success'
 && format(':white_check_mark: *{0}:* deployed successfully', inputs.env-values-path)
 || format(':x: *{0}:* deployment failed. Check the pipeline {1}/{2}/actions/runs/{3}', inputs.env-values-path, github.server_url, github.repository, github.run_id)
 }}"
 }

What's being changed (if available, include any code snippets, screenshots, or gifs):

Adding 1 more paragraph to Status check functions with link to https://docs.github.com/en/actions/reference/contexts-reference#job-context describing how to access same info like success() / failure() outside if conditionals

Check off the following:

  • A subject matter expert (SME) has reviewed the technical accuracy of the content in this PR. In most cases, the author can be the SME. Open source contributions may require an SME review from GitHub staff.
  • The changes in this PR meet the docs fundamentals that are required for all content.
  • All CI checks are passing and the changes look good in the review environment.

Copy link

welcome bot commented Jul 23, 2025

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jul 23, 2025
Copy link
Contributor

github-actions bot commented Jul 23, 2025
edited
Loading

How to review these changes 👓

Thank you for your contribution. To review these changes, choose one of the following options:

A Hubber will need to deploy your changes internally to review.

Table of review links

Note: Please update the URL for your staging server or codespace.

The table shows the files in the content directory that were changed in this pull request. This helps you review your changes on a staging server. Changes to the data directory are not included in this table.

Source Review Production What Changed
actions/reference/workflows-and-actions/expressions.md fpt
ghec
ghes@ 3.17 3.16 3.15 3.14
fpt
ghec
ghes@ 3.17 3.16 3.15 3.14

Key: fpt: Free, Pro, Team; ghec: GitHub Enterprise Cloud; ghes: GitHub Enterprise Server

🤖 This comment is automatically generated.

Copy link
Contributor

@arxeiss Thanks for opening an issue and PR about this! I'm glad you found a function that made your life easier. I'll definitely look into why it's not documented and whether it should be!

@Sharra-writes Sharra-writes added content This issue or pull request belongs to the Docs Content team github_actions Pull requests that update GitHub Actions code and removed triage Do not begin working on this issue until triaged by the team labels Jul 23, 2025
Copy link
Contributor Author

arxeiss commented Aug 27, 2025

@Sharra-writes any updates on this? In my opinion this is still valid update.

If my PR is missing anything, let me know

Copy link
Contributor

@arxeiss The only update is that I have a really long queue of questions about Actions, and the team is responding slowly in part because people have been/are on vacation, and in part because Actions is complicated with a lot of specialization. This hasn't fallen off my list.

Copy link
Contributor Author

arxeiss commented Aug 27, 2025

Understand. Thank you for update

This comment was marked as spam.

@github github deleted a comment from bloodlust6969 Sep 2, 2025
@github github deleted a comment from bloodlust6969 Sep 2, 2025
@Sharra-writes Sharra-writes added this pull request to the merge queue Sep 3, 2025
Merged via the queue into github:main with commit 5e39168 Sep 3, 2025
41 checks passed
Copy link
Contributor

github-actions bot commented Sep 3, 2025

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Sharra-writes Sharra-writes Sharra-writes approved these changes

+1 more reviewer

@thyeggman thyeggman thyeggman left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
content This issue or pull request belongs to the Docs Content team github_actions Pull requests that update GitHub Actions code
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add instructions how to use status check outside if conditionals

AltStyle によって変換されたページ (->オリジナル) /