Skip to content

Commit 39fd42c

Browse files
committed
Move daily fetch from GitHub Actions to bash script
1 parent 557543c commit 39fd42c

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

.github/workflows/daily-build.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Workflow for fetching daily images and deploying to Cloudflare Pages
2-
name: Fetch daily images and deploy to Cloudflare Pages
1+
# Workflow for fetching daily.json and deploying to Cloudflare Pages
2+
name: Fetch daily.json and deploy to Cloudflare Pages
33

44
on:
55
# Runs daily at 02:30AM UTC (08:00AM IST)
@@ -29,27 +29,13 @@ jobs:
2929
- name: Checkout
3030
uses: actions/checkout@v4
3131

32-
- name: Install Python dependencies
33-
run: python -m pip install --upgrade instaloader
34-
- name: Change directory to scripts
35-
run: cd scripts
36-
37-
- name: Fetch daily images
38-
run: instaloader -F -c 5 --latest-stamps daily.stamps --dirname-pattern daily blr.on.this.day
39-
40-
- name: Build daily.json
41-
run: python daily.py
42-
43-
- name: Upload daily images
44-
run: aws s3 sync ./daily/ ${{ secrets.S3_DESTINATION_DIR }} --endpoint-url ${{ secrets.S3_ENDPOINT }}
45-
env:
46-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
47-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
32+
- name: Fetch daily.json
33+
run: curl -L https://media.blryesterday.com/daily.json -o static/daily.json
4834

4935
- id: auto-commit-action
5036
uses: stefanzweifel/git-auto-commit-action@v5
5137
with:
52-
commit_message: Update daily images
38+
commit_message: Update daily.json
5339

5440
deploy:
5541
needs: fetch

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ vite.config.ts.timestamp-*
2222

2323
# Other
2424
scripts/daily
25+
scripts/daily.json
26+
scripts/daily.stamps

scripts/daily.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Path to the directory containing the files
1313
DATA_DIR = Path(__file__).parent / "daily"
14-
OUTPUT_FILE = Path(__file__).parent / ".." / "static" / "daily.json"
14+
OUTPUT_FILE = Path(__file__).parent / "daily.json"
1515

1616

1717
def parse_filename(filename):

scripts/daily.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Source .env
4+
source .env
5+
6+
# Change directory to scripts
7+
cd scripts
8+
9+
# Fetch latest images
10+
~/.local/bin/instaloader -F -c 5 --latest-stamps daily.stamps --dirname-pattern daily blr.on.this.day
11+
12+
# Build daily JSON
13+
python3 daily.py
14+
15+
# Upload latest images
16+
aws s3 sync --include "*.jpg" ./daily/ "$S3_DESTINATION/daily/" --endpoint-url "$S3_ENDPOINT"
17+
18+
# Upload daily JSON
19+
aws s3 cp daily.json "$S3_DESTINATION/daily.json" --endpoint-url "$S3_ENDPOINT"

scripts/daily.stamps

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)