Skip to content

Commit

Permalink
Notification + diff
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderM91 committed Oct 17, 2024
1 parent c06e45c commit c247375
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 97 deletions.
78 changes: 14 additions & 64 deletions .github/compare-images.sh
Original file line number Diff line number Diff line change
@@ -1,88 +1,38 @@
#!/bin/bash

# Set variables
CURRENT_TAG=$1
PREVIOUS_TAG=$2

# Run the current image and capture output
docker run -i --rm "$CURRENT_TAG" sh -s <<'EOF' > current-output.txt
# Output installed PHP extensions
docker-php-source extract
echo "Installed extensions"
echo "===================="
for ext in `ls /usr/src/php/ext`; do
echo ' ' `php -r "if (extension_loaded('$ext' !== 'opcache' ? '$ext' : 'Zend OPcache')) { echo '[x] $ext'; } else { echo '[ ] $ext'; }"`;
done
# Output disabled PHP extensions
echo ""
echo "Disabled extensions"
echo "===================="
for f in /usr/local/etc/php/disabled/*.ini; do
disabled=$(basename $f | sed -e 's/\.ini$//');
echo " [ ] ${disabled} $(PHP_INI_SCAN_DIR=:/usr/local/etc/php/disabled php -r "echo phpversion('${disabled}');")";
done
# List installed PECL extensions
echo ""
echo "PECL extensions"
echo "===================="
pear list -c pecl
# Check if a tag is provided
if [ -z "$1" ]; then
echo "Error: No tag provided. Usage: ./compare-image.sh <docker-tag>"
exit 1
fi

# Output the Composer version
echo ""
echo "Composer"
echo "===================="
composer -V
# Set the Docker image tag
IMAGE_TAG=$1

# List installed system packages
echo ""
echo "Installed system packages"
echo "=========================="
apk info -vv | sort
EOF

docker run -i --rm "$PREVIOUS_TAG" sh -s <<'EOF' > previous-output.txt
# Output installed PHP extensions
# Run the Docker image and output the required information
docker run -i --rm "$IMAGE_TAG" sh -s <<'EOF'
echo "=== Installed PHP Extensions ==="
docker-php-source extract
echo "Installed extensions"
echo "===================="
for ext in `ls /usr/src/php/ext`; do
echo ' ' `php -r "if (extension_loaded('$ext' !== 'opcache' ? '$ext' : 'Zend OPcache')) { echo '[x] $ext'; } else { echo '[ ] $ext'; }"`;
done
# Output disabled PHP extensions
echo ""
echo "Disabled extensions"
echo "===================="
echo "=== Disabled PHP Extensions ==="
for f in /usr/local/etc/php/disabled/*.ini; do
disabled=$(basename $f | sed -e 's/\.ini$//');
echo " [ ] ${disabled} $(PHP_INI_SCAN_DIR=:/usr/local/etc/php/disabled php -r "echo phpversion('${disabled}');")";
done
# List installed PECL extensions
echo ""
echo "PECL extensions"
echo "===================="
echo "=== PECL Extensions ==="
pear list -c pecl
# Output the Composer version
echo ""
echo "Composer"
echo "===================="
echo "=== Composer Version ==="
composer -V
# List installed system packages
echo ""
echo "Installed system packages"
echo "=========================="
echo "=== Installed System Packages ==="
apk info -vv | sort
EOF

# Compare the outputs
if [ -f previous-output.txt ]; then
echo "Comparing current and previous outputs..."
diff previous-output.txt current-output.txt || true
else
echo "No previous output to compare."
fi
72 changes: 39 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,45 @@ jobs:
tags: ${{ join(matrix.tags) }}
platforms: ${{ join(matrix.platforms) }}

- name: Compare images and capture diff
- name: Output image report
run: |
CURRENT_TAG=${{ matrix.tags[0] }}
PREVIOUS_TAG="${{ matrix.tags[0] }}-${{ env.PREV_COMMIT_HASH }}"
bash .github/compare-images.sh $CURRENT_TAG $PREVIOUS_TAG > image-diff.txt || true
bash .github/compare-images.sh > image-report.txt || true
cat image-report.txt
- name: Read diff output
id: read_diff
run: |
DIFF_OUTPUT=$(cat image-diff.txt)
echo "DIFF_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$DIFF_OUTPUT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Send Slack Notification
uses: slackapi/[email protected]
with:
payload: |
{
"attachments": [
{
"pretext": "Release changes for *spryker/php:${{ matrix.tags[0] }}*",
"color": "good",
"fields": [
{
"title": "Image diff:",
"value": "${{ env.DIFF_OUTPUT }}",
"short": false
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
# - name: Compare images and capture diff
# run: |
# CURRENT_TAG=${{ matrix.tags[0] }}
# PREVIOUS_TAG="${{ matrix.tags[0] }}-${{ env.PREV_COMMIT_HASH }}"
# bash .github/compare-images.sh $CURRENT_TAG $PREVIOUS_TAG > image-diff.txt || true
#
# - name: Read diff output
# id: read_diff
# run: |
# DIFF_OUTPUT=$(cat image-diff.txt)
# echo "DIFF_OUTPUT<<EOF" >> $GITHUB_ENV
# echo "$DIFF_OUTPUT" >> $GITHUB_ENV
# echo "EOF" >> $GITHUB_ENV
#
# - name: Send Slack Notification
# uses: slackapi/[email protected]
# with:
# payload: |
# {
# "attachments": [
# {
# "pretext": "Release changes for *spryker/php:${{ matrix.tags[0] }}*",
# "color": "good",
# "fields": [
# {
# "title": "Image diff:",
# "value": "${{ env.DIFF_OUTPUT }}",
# "short": false
# }
# ]
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 comments on commit c247375

Please sign in to comment.