Skip to content

Commit

Permalink
Add previous and current build directories, run containers with volum…
Browse files Browse the repository at this point in the history
…e mounts, generate file and size differences
  • Loading branch information
paskal committed Nov 1, 2024
1 parent 9579a3e commit da6da7d
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions .github/workflows/ci-build-site.yml
Original file line number Diff line number Diff line change
@@ -48,39 +48,66 @@ jobs:
run: |
git checkout ${{ steps.get-comparison-commit.outputs.compare_sha }}
docker build -t radio-t/site:previous .
docker run --rm -v ${{ github.workspace }}/public-prev:/srv/hugo/public radio-t/site:previous
# Create directories for previous build
mkdir -p hugo-prev/hugo
cp -r hugo/* hugo-prev/hugo/
mkdir -p hugo-prev/public
# Run the container with proper volume mounts
docker run --rm \
-v ${{ github.workspace }}/hugo-prev/hugo:/srv/hugo \
-v ${{ github.workspace }}/hugo-prev/public:/srv/hugo/public \
radio-t/site:previous
- name: Build current version
run: |
git checkout ${{ github.event.pull_request.head.sha || github.sha }}
docker build -t radio-t/site:current .
docker run --rm -v ${{ github.workspace }}/public-current:/srv/hugo/public radio-t/site:current
# Create directories for current build
mkdir -p hugo-current/hugo
cp -r hugo/* hugo-current/hugo/
mkdir -p hugo-current/public
# Run the container with proper volume mounts
docker run --rm \
-v ${{ github.workspace }}/hugo-current/hugo:/srv/hugo \
-v ${{ github.workspace }}/hugo-current/public:/srv/hugo/public \
radio-t/site:current
- name: Generate diff
run: |
# Create a directory for the diff
mkdir -p site-diff
# Generate diff for HTML files
diff -r -N -u public-prev public-current > site-diff/changes.diff || true
diff -r -N -u hugo-prev/public hugo-current/public > site-diff/changes.diff || true
# Generate a summary of changed files
echo "Changed files:" > site-diff/summary.txt
find public-current -type f -exec sh -c '
prev_file="public-prev/${1#public-current/}"
find hugo-current/public -type f -exec sh -c '
prev_file="hugo-prev/public/${1#hugo-current/public/}"
if [ ! -f "$prev_file" ]; then
echo "New: ${1#public-current/}"
echo "New: ${1#hugo-current/public/}"
elif ! cmp -s "$1" "$prev_file"; then
echo "Modified: ${1#public-current/}"
echo "Modified: ${1#hugo-current/public/}"
fi
' sh {} \; >> site-diff/summary.txt
find public-prev -type f -exec sh -c '
current_file="public-current/${1#public-prev/}"
find hugo-prev/public -type f -exec sh -c '
current_file="hugo-current/public/${1#hugo-prev/public/}"
if [ ! -f "$current_file" ]; then
echo "Deleted: ${1#public-prev/}"
echo "Deleted: ${1#hugo-prev/public/}"
fi
' sh {} \; >> site-diff/summary.txt
# Add size comparison
echo -e "\nSize comparison:" >> site-diff/summary.txt
echo "Previous build:" >> site-diff/summary.txt
du -sh hugo-prev/public >> site-diff/summary.txt
echo "Current build:" >> site-diff/summary.txt
du -sh hugo-current/public >> site-diff/summary.txt
- name: Upload diff artifacts
uses: actions/upload-artifact@v4

0 comments on commit da6da7d

Please sign in to comment.