-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add file watcher for shopware/shopware (#1209)
* Add more test files * Test error * Optimize loop * Remove output * Add word and rename repo * Add new filters to pyspelling * Adjust comments * Remove test file * Remove test file * Minor fix from review dog
- Loading branch information
1 parent
f2b7b7f
commit a9f8e64
Showing
16 changed files
with
138 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Set the path to the snippets folder | ||
WATCHER_PATH=$1 | ||
COUNTER=0 | ||
ERROR_FOUND=0 | ||
|
||
|
||
# Find all files in the snippets folder | ||
while IFS= read -r -d '' file; do | ||
# Check if the file contains the string "WATCHER_URL" and is therefore a watcher file | ||
cat "$file" | grep 'WATCHER_URL' >> /dev/null || continue | ||
((COUNTER++)) | ||
|
||
# Get the JSON from the first line of the file | ||
HEAD=$(cat "$file" | grep 'WATCHER_URL') | ||
JSON=$(sed "s/<!-- //;s/ -->//" <<< "$HEAD") | ||
|
||
# Get the values from the JSON | ||
WATCHER_URL=$(echo $JSON | jq -r '.WATCHER_URL') | ||
WATCHER_HASH=$(echo $JSON | jq -r '.WATCHER_HASH') | ||
WATCHER_CONTAINS=$(echo $JSON | jq -r '.WATCHER_CONTAINS') | ||
|
||
# Get the hash of the URL | ||
EVAL_HASH="curl -sl $WATCHER_URL | md5sum | cut -d ' ' -f 1" | ||
CALLED_HASH="$(eval $EVAL_HASH)" | ||
|
||
# Check if the hashes are equal | ||
if [ "$WATCHER_HASH" == "$CALLED_HASH" ]; then | ||
echo "Both hashes are equal." | ||
else | ||
echo "Hashes are not equal." | ||
|
||
FILE_CONTENT=$(curl -sl $WATCHER_URL) | ||
|
||
# Check if $WATCHER_CONTAINS contains the string "null" and is therefore empty or not set | ||
if [[ $WATCHER_CONTAINS == "null" ]]; then | ||
ERROR_FOUND=1 | ||
echo "Sourcefile: https://github.com/shopware/docs/blob/main/$file" | ||
fi | ||
# Check if $WATCHER_CONTAINS contains the string $WATCHER_CONTAINS and if not call the Slack webhook | ||
if [[ $FILE_CONTENT == *"$WATCHER_CONTAINS"* ]]; then | ||
echo "String found!" | ||
else | ||
echo "String not found! Please check $WATCHER_URL" | ||
echo "Sourcefile: https://github.com/shopware/docs/blob/main/$file" | ||
ERROR_FOUND=1 | ||
fi | ||
fi | ||
done < <(find $WATCHER_PATH -type f -regex '.*\.\(md\|yaml\)$' -print0) | ||
|
||
echo "Found $COUNTER files with a watcher tag." | ||
|
||
if [ "$ERROR_FOUND" -eq 1 ] | ||
then | ||
echo "Error found, exiting..." | ||
exit 1 | ||
else | ||
echo "No error found, exiting..." | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Check shopware files for changes | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
./.github/scripts/file-watcher.sh | ||
id: watcher | ||
continue-on-error: true | ||
- name: Send custom JSON data to Slack workflow | ||
if: steps.watcher.outcome != 'success' | ||
id: slack | ||
uses: slackapi/[email protected] | ||
with: | ||
payload: | | ||
{ | ||
"text": "Text: GitHub Action build result: ${{ job.status }}", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": ":ladybug: Failed file watcher with status '${{ steps.watcher.outcome }}': Please check ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters