Update Index #4440
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: Update Index | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "34 * * * *" | |
jobs: | |
update_index: | |
environment: r2-prod | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout main | |
uses: actions/checkout@v4 | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install hatch | |
run: python -m pip install hatch | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/65154078780/locations/global/workloadIdentityPools/github/providers/py-wtf | |
service_account: [email protected] | |
project_id: pypinfo-214114 | |
export_environment_variables: true | |
- name: Index | |
run: set -x; python -m hatch run py-wtf index-since --since "$(date -d '1hour ago' '+%Y-%m-%d %H:%M:%S')" _index | |
- name: Compress index | |
run: gzip -9 _index/*.json | |
- name: Upload | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
run: | | |
aws s3 sync \ | |
_index s3://${{secrets.R2_BUCKET}}/_index \ | |
--exclude '*' --include '*.json.gz' \ | |
--no-guess-mime-type --content-encoding gzip \ | |
--content-type application/json --checksum-algorithm CRC32 | |
aws s3 cp \ | |
_index/.metadata s3://${{secrets.R2_BUCKET}}/_index/.metadata \ | |
--content-type application/json --checksum-algorithm CRC32 |