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

Action is incorrectly detecting success and not sending notification #111

Open
ylhan opened this issue Jul 20, 2023 · 1 comment
Open

Action is incorrectly detecting success and not sending notification #111

ylhan opened this issue Jul 20, 2023 · 1 comment
Assignees

Comments

@ylhan
Copy link

ylhan commented Jul 20, 2023

Screenshot 2023-07-20 at 4 16 26 PM

You can see here that the previous steps failed however notify-slack-action's status is set to success which causes it not to alert since I have notify-when failure set.

Here's my custom action:

name: "Safe Amazon ECS Deploy Task Definition"
description: 'Deploy an Amazon ECS task definition "safely" (verify that the deployment was not rolled back)'
inputs:
  service-name:
    description: "The name of the service being deployed"
    required: true
    type: string
  task-definition:
    description: "The task definition to deploy"
    required: true
    type: string
  cluster:
    description: "The cluster to deploy to"
    required: true
    type: string

runs:
  using: "composite"
  steps:
    - name: Deploy Amazon ECS task definition
      uses: aws-actions/amazon-ecs-deploy-task-definition@v1
      id: ecs-deploy
      with:
        task-definition: ${{ inputs.task-definition }}
        service: ${{ inputs.service-name }}
        cluster: ${{ inputs.cluster }}
        wait-for-service-stability: true
    - name: Check if deployment was successful
      id: check-deployment
      if: always()
      run: |
        CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster ${{ inputs.cluster }} --services ${{ inputs.service-name }} --query services[0].deployments[0].taskDefinition | jq -r ".")
        NEW_TASK_DEF_ARN=${{ steps.ecs-deploy.outputs.task-definition-arn }}
        echo "Current task arn: $CURRENT_TASK_DEF_ARN"
        echo "New task arn: $NEW_TASK_DEF_ARN"
        if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then
          echo "Deployment failed."
          exit 1
        fi
      shell: bash
    - name: Report Status
      if: always()
      uses: ravsamhq/notify-slack-action@v1
      with:
        status: ${{ job.status }}
        notification_title: "{workflow} has {status_message}"
        message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> | <{run_url}|View Run>"
        footer: "Linked Repo <{repo_url}|{repo}>"
        # Only alert on failure to prevent spamming the channel
        notify_when: "failure"
@ravsam-bot
Copy link
Contributor

ravsam-bot bot commented Jul 20, 2023

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].

@ylhan ylhan changed the title Status is set to success in failed custom action Action is incorrectly detecting success and not sending notification Jul 20, 2023
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