ci: avoid redundant S3 uploads (#326)

Co-authored-by: Hermes Agent <hermes-agent@users.noreply.github.com>
This commit is contained in:
SirBroccoli
2026-07-19 11:16:14 +02:00
committed by GitHub
co-authored by Hermes Agent
parent a2c70780d3
commit 7e5ea5c1f8
4 changed files with 205 additions and 2 deletions
+13 -2
View File
@@ -153,9 +153,20 @@ jobs:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
# Sync the build to S3
# Sync the build to S3. mdBook refreshes mtimes on every build, so first
# age byte-identical files based on S3 ETags; `s3 sync` then uploads only
# genuinely changed/new output while retaining normal --delete behavior.
- name: Sync to S3
run: aws s3 sync ./book s3://hacktricks-cloud/en --delete
run: |
aws s3api list-objects-v2 \
--bucket hacktricks-cloud \
--prefix en/ \
--output json > /tmp/s3-en-manifest.json
python3 scripts/mark_unchanged_s3_files.py \
--source ./book \
--manifest /tmp/s3-en-manifest.json \
--remote-prefix en/
aws s3 sync ./book s3://hacktricks-cloud/en --delete
- name: Upload root sitemap index
run: |
+11
View File
@@ -84,6 +84,7 @@ jobs:
wget -O /tmp/compare_and_fix_refs.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/compare_and_fix_refs.py
wget -O /tmp/translator.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/translator.py
wget -O /tmp/seo_postprocess.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/seo_postprocess.py
cp scripts/mark_unchanged_s3_files.py /tmp/mark_unchanged_s3_files.py
- name: Run get_and_save_refs.py
run: |
@@ -272,6 +273,16 @@ jobs:
echo "Current branch:"
git rev-parse --abbrev-ref HEAD
echo "Syncing $BRANCH to S3"
# mdBook refreshes mtimes on every build. Age byte-identical files
# based on single-part S3 ETags so `s3 sync` skips redundant PUTs.
aws s3api list-objects-v2 \
--bucket hacktricks-cloud \
--prefix "$BRANCH/" \
--output json > /tmp/s3-branch-manifest.json
python3 /tmp/mark_unchanged_s3_files.py \
--source ./book \
--manifest /tmp/s3-branch-manifest.json \
--remote-prefix "$BRANCH/"
aws s3 sync ./book s3://hacktricks-cloud/$BRANCH --delete
echo "Sync completed"
echo "Cat 3 files from the book"