Daily Consensus Update #166
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Daily Consensus Update | |
| on: | |
| schedule: | |
| # Run daily at 06:00 UTC (after Tor consensus refresh cycle) | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| # Allow manual trigger | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| update-consensus: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Fetch fresh consensus | |
| run: | | |
| chmod +x scripts/fetch-consensus.sh | |
| ./scripts/fetch-consensus.sh webtor/src/cached | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if git diff --quiet webtor/src/cached/; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No consensus changes detected" | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Consensus updated" | |
| fi | |
| - name: Commit updated consensus | |
| if: steps.check_changes.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add webtor/src/cached/ | |
| git commit -m "chore: update cached Tor consensus $(date -u +%Y-%m-%d)" | |
| git push | |
| build-and-deploy: | |
| needs: update-consensus | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (with latest consensus) | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Pull latest changes | |
| run: git pull origin main | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Build WASM demo | |
| run: wasm-pack build webtor-demo --target web --out-dir pkg --release | |
| - name: Prepare static files | |
| run: | | |
| mkdir -p webtor-demo/static/pkg | |
| cp -r webtor-demo/pkg/* webtor-demo/static/pkg/ | |
| # Create brotli-compressed consensus files for lazy loading | |
| brotli -f -k webtor/src/cached/consensus.txt | |
| brotli -f -k webtor/src/cached/microdescriptors.txt | |
| cp webtor/src/cached/consensus.txt.br webtor-demo/static/ | |
| cp webtor/src/cached/microdescriptors.txt.br webtor-demo/static/ | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./webtor-demo/static | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build-and-deploy | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |