-
-
Notifications
You must be signed in to change notification settings - Fork 5
34 lines (27 loc) · 1.2 KB
/
s3_cache_control.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Update S3 Cache-Control
on:
schedule:
- cron: "0 0 * * *" # This runs daily at midnight UTC.
workflow_dispatch:
jobs:
update-cache-control:
runs-on: ubuntu-latest
steps:
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"
- name: Update S3 Cache-Control
run: |
BUCKET_NAME="neofoodclub"
CACHE_CONTROL_VALUE="public, max-age=31536000"
DAYS_OLD=2
# Curl the URL and store the result in a variable
current_round=$(curl -s https://cdn.neofood.club/current_round.txt)
# Subtract DAYS_OLD from the current round
let previous_round=current_round-DAYS_OLD
# Update the Cache-Control header for that objects data
aws s3api copy-object --bucket $BUCKET_NAME --key "rounds/$previous_round.json" --copy-source "$BUCKET_NAME/rounds/$previous_round.json" --metadata-directive REPLACE --cache-control "$CACHE_CONTROL_VALUE"
echo "Cache-Control updated for: rounds/$previous_round.json"