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

notify_when: 'failure' notifies when workflow passes with warnings #50

Open
tubbo opened this issue Jul 26, 2022 · 3 comments
Open

notify_when: 'failure' notifies when workflow passes with warnings #50

tubbo opened this issue Jul 26, 2022 · 3 comments
Assignees

Comments

@tubbo
Copy link

tubbo commented Jul 26, 2022

We are seeing notifications for passing builds with "warnings" in Slack when we have notify_when: 'failure' set.

This only happens on a job that runs a Bash script in which there's a fallback for the initial action failing.

Screen Shot 2022-07-26 at 12 30 33 PM

Our workflow looks like this:

name: Mergedown
on:
  push:
    branches:
      - main
    paths-ignore:
      - '*/CHANGELOG.md'
      - CHANGELOG.md
      - package.json
jobs:
  mergedown:
    name: Mergedown
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Source Code
        uses: actions/[email protected]
        with:
          fetch-depth: 0
          token: ${{ secrets.MERGEDOWN_TOKEN }}
      - name: Merge Updates from Main into Release Branches
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          git config user.name "${{ github.actor }}"
          git config user.email "${{ github.actor}}@users.noreply.github.com"
          for BRANCH in $(git branch --all --list | grep remotes/origin/release | sed 's/remotes\/origin\///g')
          do
            echo "Merging 'main' into '$BRANCH'..."
            git checkout $BRANCH
            git merge --no-verify origin/main && git push origin $BRANCH || (
              echo "Automatic mergedown failed for $BRANCH. Finding PR..."

              PR=$(
                gh api graphql \
                  --jq '.data.repository.pullRequests.nodes[0].id' \
                  -F branch="$BRANCH" \
                  -f query='
                    query FindPullRequest($branch: String!) {
                      repository(owner: "[REDACTED]", name: "[REDACTED]") {
                        pullRequests(headRefName: $branch, first: 1) {
                          nodes {
                            id
                          }
                        }
                      }
                    }
                  '
              )

              if [[ ! -z $PR ]]; then
                echo "Commenting on pull request with global ID $PR"

                gh api graphql \
                  -F pr=$PR \
                  -f query='
                    mutation AddComment($pr: ID!) {
                      addComment(input: {
                        body: "Mergedown of ${{ github.sha }} has failed.",
                        subjectId: $pr
                      }) {
                        clientMutationId
                      }
                    }'
              fi

              git merge --abort
            )
          done
      - name: Report Workflow Failure to Slack
        if: always()
        uses: ravsamhq/notify-slack-action@v1
        with:
          status: ${{ steps.decider.outputs.result }}
          notify_when: 'failure'
          message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>'
          notification_title: Mergedown failed. This is probably an issue with the workflow, not an individual branch.
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SOFTWARE_WEBHOOK_URL }}

This job passes in GitHub, and it's unclear from the output why it is throwing any warnings:

Screen Shot 2022-07-26 at 12 31 21 PM

I suspect it has something to do with run's output and me misunderstanding how the (do this) || (or this if that doesn't work) technique in bash for falling back to another command if the first one fails, but either way I do see that notify_when allows me to specify if I want "passed with warnings" to be one of the statuses, so I'm thinking this action shouldn't be sending me the notification regardless.

edit:

This line of code might be the culprit: status: ${{ steps.decider.outputs.result }}

I copy/pasted this particular action from another workflow which has a "decider" step, but this one doesn't. I guess GitHub still lets this through but might just set this to status: null? Anyway, this could be the issue right here, as when I changed this to just use ${{ job.status }}, my warning notifications went away.

Is it possible that this action threw the warning, and it was just buried because it was the one actually doing the work of notifying me?

@ravsam-bot
Copy link
Contributor

ravsam-bot bot commented Jul 26, 2022

Hello and welcome to RavSam 💜. Thanks for opening your first issue. I will assign one of our team members to take a look at the problem you have raised. Make sure to include as much information as possible to help our team diagnose the issue and solve it quickly.

If the problem is related to a security concern, then please delete this issue and send us an email at [email protected].

@ketiko
Copy link

ketiko commented Aug 2, 2022

I am also seeing this behavior.

@ravgeetdhillon
Copy link
Member

@tubbo @ketiko To get rid of the slow build speeds of Docker, we have released v2 which is written in Typescript. See this comment for more information.

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

3 participants