mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-06-12 19:11:44 -07:00
Merge pull request #302 from HackTricks-wiki/fix/hermes-root-sitemap-invalidation
ci: skip unchanged root sitemap invalidations
This commit is contained in:
@@ -275,16 +275,29 @@ jobs:
|
|||||||
find . -type f -name 'index.html' -print | head -n 3 | xargs -r cat
|
find . -type f -name 'index.html' -print | head -n 3 | xargs -r cat
|
||||||
|
|
||||||
- name: Refresh root sitemap index
|
- name: Refresh root sitemap index
|
||||||
|
id: root_sitemap
|
||||||
run: |
|
run: |
|
||||||
LANGS=$(aws s3api list-objects-v2 --bucket hacktricks-cloud --delimiter / --query 'CommonPrefixes[].Prefix' --output text | tr '\t' '\n' | sed 's:/$::' | grep -E '^[a-z]{2}$' | sort | paste -sd, -)
|
set -euo pipefail
|
||||||
|
LANGS=$(aws s3api list-objects-v2 --bucket hacktricks-cloud --delimiter / --query 'CommonPrefixes[].Prefix' --output text | tr '\t' '\n' | sed 's:/$::' | grep -E '^[a-z]{2}$' | sort | paste -sd, - || true)
|
||||||
if [ -z "$LANGS" ]; then
|
if [ -z "$LANGS" ]; then
|
||||||
LANGS="en"
|
LANGS="en"
|
||||||
fi
|
fi
|
||||||
python3 /tmp/seo_postprocess.py index --site-url https://cloud.hacktricks.wiki --languages "$LANGS" --output ./sitemap.xml
|
python3 /tmp/seo_postprocess.py index --site-url https://cloud.hacktricks.wiki --languages "$LANGS" --output ./sitemap.xml
|
||||||
|
if aws s3 cp s3://hacktricks-cloud/sitemap.xml /tmp/current-root-sitemap.xml >/dev/null 2>&1 && cmp -s /tmp/current-root-sitemap.xml ./sitemap.xml; then
|
||||||
|
echo "Root sitemap unchanged; skipping S3 upload and CloudFront invalidation for /sitemap.xml"
|
||||||
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
aws s3 cp ./sitemap.xml s3://hacktricks-cloud/sitemap.xml --content-type application/xml --cache-control max-age=300
|
aws s3 cp ./sitemap.xml s3://hacktricks-cloud/sitemap.xml --content-type application/xml --cache-control max-age=300
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Invalidate CloudFront HTML and SEO assets
|
- name: Invalidate CloudFront HTML and SEO assets
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
paths=("/$BRANCH/*" "/$BRANCH/sitemap.xml")
|
||||||
|
if [ "${{ steps.root_sitemap.outputs.changed }}" = "true" ]; then
|
||||||
|
paths+=("/sitemap.xml")
|
||||||
|
fi
|
||||||
aws cloudfront create-invalidation \
|
aws cloudfront create-invalidation \
|
||||||
--distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}" \
|
--distribution-id "${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}" \
|
||||||
--paths "/$BRANCH/*" "/sitemap.xml" "/$BRANCH/sitemap.xml"
|
--paths "${paths[@]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user