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

Chatops command /format output message if nothing updated #2021

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/chatops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ jobs:
with:
go-version: ${{ steps.golang_version.outputs.version }}
- name: update and push
id: format_push
if: steps.check_comments_format.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true'
run: |
export PATH=$(go env GOPATH)/bin:$PATH
Expand All @@ -478,8 +479,10 @@ jobs:
git checkout go.mod go.sum

if git diff --quiet --exit-code; then
echo "UPDATED=false" >> $GITHUB_OUTPUT
echo "Nothing updated"
else
echo "UPDATED=true" >> $GITHUB_OUTPUT
git add .
git commit -S --signoff -m ":robot: Update license headers / Format go codes and yaml files"

Expand All @@ -492,6 +495,19 @@ jobs:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
PR_INFO_URL: ${{ github.event.issue.pull_request.url }}
PR_NUM: ${{ github.event.issue.number }}
- name: no changes
if: steps.check_comments_format.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' && steps.format_push.outputs.UPDATED == 'false'
run: |
curl --include --verbose --fail \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
--request POST \
--data "{\"body\": \"**[FORMAT]** Nothing to format.\"}" \
$API_URL
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
API_URL: ${{ github.event.issue.comments_url }}
- name: failure comment
if: failure()
run: |
Expand Down