Skip to content

Commit

Permalink
ci: Fix docker ChatOps command notification (#5189)
Browse files Browse the repository at this point in the history
ci: Fix docker chatops command notification
  • Loading branch information
nikitabelonogov authored Dec 14, 2023
1 parent 0050cd4 commit 40a5e4a
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/docker-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,40 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Add reaction to command comment on success
uses: peter-evans/create-or-update-comment@v3
if: needs.build-docker.result != 'failure'
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Docker image was pushed with the tag `${{ needs.build-docker.outputs.build_version }}`
reactions: "+1"
- name: Details
id: details
shell: bash
run: |
set -xeuo pipefail
case "${{ needs.build-docker.result }}" in
success)
echo "comment=Docker image was pushed with the tag `${{ needs.build-docker.outputs.build_version }}`" >> $GITHUB_OUTPUT
echo "reaction=+1" >> $GITHUB_OUTPUT
;;
skipped)
echo "comment=Workflow has been skipped" >> $GITHUB_OUTPUT
echo "reaction=confused" >> $GITHUB_OUTPUT
;;
cancelled)
echo "comment=Workflow has been canceled" >> $GITHUB_OUTPUT
echo "reaction=confused" >> $GITHUB_OUTPUT
;;
*)
echo "comment=**Error**: failed to execute \"${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}\" command" >> $GITHUB_OUTPUT
echo "reaction=-1" >> $GITHUB_OUTPUT
;;
esac
- name: Add reaction to command comment on failure
- name: Add reaction to command comment
uses: peter-evans/create-or-update-comment@v3
if: needs.build-docker.result == 'failure'
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
reactions: "-1"
> ${{ steps.details.outputs.comment }}
reactions: ${{ steps.details.outputs.reaction }}

help:
if: github.event.client_payload.slash_command.args.unnamed.arg1 == 'help'
Expand Down

0 comments on commit 40a5e4a

Please sign in to comment.