Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mghilardelli authored Oct 17, 2024
1 parent c117067 commit 63d36fa
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ jobs:
echo "Issue Body: ${{ github.event.issue.body }}"
echo "User: ${{ github.event.issue.user.login }}"
# Extract previous issue body from the webhook event
PREVIOUS_BODY="${{ github.event.changes.body.from }}"
echo "Previous Body: $PREVIOUS_BODY"
# Extract currently checked checkboxes
CURRENT_CHECKED=$(echo "${{ github.event.issue.body }}" | grep -E '\- \[x\]')
PREVIOUS_CHECKED=$(echo "$PREVIOUS_BODY" | grep -E '\- \[x\]')
# Check if there are new checked checkboxes
NEW_CHECKED_LINES=$(echo "$CURRENT_CHECKED" | grep -Fxv -f <(echo "$PREVIOUS_CHECKED"))
# Check if any checkbox is checked
if echo "${{ github.event.issue.body }}" | grep -q '\- \[x\]'; then
echo "Checkbox checked."
if [ -n "$NEW_CHECKED_LINES" ]; then
echo "Newly checked checkboxes found:"
echo "$NEW_CHECKED_LINES"
echo "checkbox_checked=true" >> $GITHUB_OUTPUT
echo "new_checked_lines=$NEW_CHECKED_LINES" >> $GITHUB_OUTPUT
else
echo "No checkbox checked."
echo "checkbox_checked=false" >> $GITHUB_OUTPUT
Expand All @@ -29,10 +42,9 @@ jobs:
if: steps.check_checkbox.outputs.checkbox_checked == 'true'
run: |
USERNAME="${{ github.event.issue.user.login }}"
COMMENT="Checkbox checked by @$USERNAME!"
echo "output: ${{steps.check_checkbox.outputs.checkbox_checked}}"
NEW_CHECKED_LINES="${{ steps.check_checkbox.outputs.new_checked_lines }}"
COMMENT="Checkboxes newly checked by @$USERNAME:\n$NEW_CHECKED_LINES"
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
Expand Down

0 comments on commit 63d36fa

Please sign in to comment.