-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
029d7fb
commit d3f2a39
Showing
14 changed files
with
111 additions
and
8 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,58 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Set the path to the snippets folder | ||
WATCHER_PATH=$1 | ||
echo 0 > error.txt | ||
|
||
# Find all files in the snippets folder | ||
find $WATCHER_PATH -type f -print0 | 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 | ||
|
||
# Get the JSON from the first line of the file | ||
HEAD=$(cat "$file" | grep 'WATCHER_URL') | ||
JSON=$(sed "s/# //g" <<< "$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 | ||
echo 1 > error.txt | ||
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" | ||
echo 1 > error.txt | ||
fi | ||
fi | ||
done | ||
|
||
ERROR_FOUND=$(cat error.txt) | ||
|
||
if [ "$ERROR_FOUND" -eq 1 ] | ||
then | ||
echo "Error found, exiting..." | ||
exit 1 | ||
else | ||
echo "$ERROR_FOUND 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
shopware: | ||
html_sanitizer: | ||
enabled: false | ||
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"html_sanitizer"} |
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