Skip to content

Docs - Check docs.lakefs.io matches source #1104

Docs - Check docs.lakefs.io matches source

Docs - Check docs.lakefs.io matches source #1104

name: Docs - Check docs.lakefs.io matches source
on:
push:
branches: [ main ]
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
build-and-compare:
runs-on: ubuntu-latest
steps:
- name: Checkout Docs source
uses: actions/checkout@v3
with:
repository: treeverse/lakeFS
path: lakeFS
- name: Checkout Published Docs
uses: actions/checkout@v2
with:
repository: treeverse/docs-lakeFS
path: docs-lakeFS
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: lakeFS/docs
ruby-version: '3.2'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build Docs from Source
working-directory: lakeFS/docs
run: bundle exec jekyll build --config _config.yml,_config.version.yml
- name: Compare Generated Site to live
run: |
diff --brief --recursive docs-lakeFS lakeFS/docs/_site | \
grep -v --extended-regexp 'Only in docs-lakeFS: v?[[:digit:]]+(\.[[:digit:]]+)?' | \
grep -v -e ": .git" \
-e ": versions.json" \
-e ": CNAME" \
-e "docs-lakeFS/assets/js/search-data.json" \
-e "docs-lakeFS/posts/index.html" \
-e "docs-lakeFS/redirects.json" > /tmp/diffs.txt || true
if [ -s "/tmp/diffs.txt" ]; then
echo "## 🚨 Docs published on docs.lakefs.io don't match docs generated from source 🚨" >> $GITHUB_STEP_SUMMARY
echo " " >> $GITHUB_STEP_SUMMARY
sed 's/^/* /' /tmp/diffs.txt >> $GITHUB_STEP_SUMMARY
cat $GITHUB_STEP_SUMMARY
# If there are any mismatched files (rather than just files that
# only exist on one side) then copy them to a folder for upload
# as an artifact of the github workflow
mkdir -p /tmp/mismatched-files/docs-lakeFS
mkdir -p /tmp/mismatched-files/lakeFS/docs/_site
while read -r line; do
file1=$(echo "$line" | cut -d' ' -f2)
file2=$(echo "$line" | cut -d' ' -f4)
cp "$file1" /tmp/mismatched-files/docs-lakeFS
cp "$file2" /tmp/mismatched-files/lakeFS/docs/_site
done < <(grep -e "^Files.* and .* differ" /tmp/diffs.txt)
exit 1
else
echo "## ✅ Docs match" >> $GITHUB_STEP_SUMMARY
true
fi
- name: Upload artifacts if mismatches found
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: mismatched-files
retention-days: 5
path: |
/tmp/mismatched-files/
/tmp/diffs.txt