Upload Assets to R2 #3336
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: Upload Assets to R2 | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| schedule: | |
| - cron: '0 */3 * * *' | |
| concurrency: | |
| group: upload | |
| cancel-in-progress: false | |
| env: | |
| AWS_REGION: us-east-1 | |
| jobs: | |
| upload: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| fetch-depth: 2 | |
| - name: Configure AWS credentials | |
| run: | | |
| aws configure set aws_access_key_id ${{ secrets.R2_ACCESS_KEY_ID }} | |
| aws configure set aws_secret_access_key ${{ secrets.R2_ACCESS_SECRET_KEY }} | |
| aws configure set region ${{ env.AWS_REGION }} | |
| - name: Sync to R2 | |
| run: | | |
| aws s3 sync blockchains/ s3://${{ secrets.R2_ASSETS_BUCKET }}/blockchains/ \ | |
| --endpoint-url https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com \ | |
| --size-only \ | |
| --delete | |
| - name: Purge cache | |
| run: | | |
| git show --name-only --pretty="" HEAD -- blockchains/ > /tmp/changed.txt || true | |
| ./.github/scripts/purge-cache.sh "${{ secrets.R2_PURGE_CACHE_ZONE_ID }}" "${{ secrets.R2_PURGE_CACHE_SECRET_KEY }}" "${{ secrets.R2_PURGE_CACHE_URL }}" /tmp/changed.txt |