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

Fix Composer Lock Diff workflow for PRs that don't have composer.lock… #654

Merged
merged 2 commits into from
Aug 16, 2024
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
15 changes: 10 additions & 5 deletions scaffold/github/workflows/Security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,21 @@ jobs:

- name: Publish Results
run: |
FIRST=true
COMPOSER_LOCK_DIFF="<!-- composer-lock-diff -->
## Composer Lock Diff
$(cat composer-lock-diff.md)"
COMPOSER_LOCK_DIFF=$(echo "$COMPOSER_LOCK_DIFF" | jq -Rsa .)
FIRST=true
echo $COMPOSER_LOCK_DIFF >> $GITHUB_STEP_SUMMARY
EMPTY=true
if [ "$(cat composer-lock-diff.md)" != "" ]; then
echo $COMPOSER_LOCK_DIFF >> $GITHUB_STEP_SUMMARY
EMPTY=false
fi
curl -s -L -f -X GET \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/${{ github.repository }}/pulls/$DRAINPIPE_PR_NUMBER/comments | jq -rc '.[]|select(.body | contains("<!-- composer-lock-diff -->")) | .id' | while read i; do
if [ "$FIRST" == "true" ]; then
if [ "$FIRST" == "true" ] && [ "$EMPTY" == "false" ]; then
FIRST=false
curl -L \
-X PATCH \
Expand All @@ -67,15 +71,16 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/pulls/comments/$i \
-d "{\"body\":$COMPOSER_LOCK_DIFF}"
fi
else
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/pulls/comments/$i
fi
done
if [ "$FIRST" == "true" ]; then
if [ "$FIRST" == "true" ] && [ "$EMPTY" == "false" ]; then
curl -L -f \
-X POST \
-H "Accept: application/vnd.github+json" \
Expand Down
Loading