Skip to content

Commit 695b492

Browse files
Separate webpage build from data processing steps in action #262 (#272)
* Separate webpage build from data processing steps in action #262 * artifacts checks --------- Co-authored-by: Lukas Wallrich <[email protected]>
1 parent 46e52b0 commit 695b492

File tree

2 files changed

+97
-65
lines changed

2 files changed

+97
-65
lines changed

.github/workflows/data-processing.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Data Processing
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Daily at midnight
6+
workflow_dispatch:
7+
8+
jobs:
9+
process-data:
10+
name: Process Data
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: read
14+
env:
15+
PYTHON_VERSION: "3.11"
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ env.PYTHON_VERSION }}
24+
cache: 'pip'
25+
26+
- name: Install Python dependencies
27+
run: python3 -m pip install -r ./requirements.txt
28+
29+
- name: Run Tenzing script
30+
run: python3 scripts/forrt_contribs/tenzing.py
31+
32+
- name: Run Curated Resources script
33+
run: python3 content/resources/resource.py
34+
35+
- name: Move and validate Tenzing output
36+
run: |
37+
mv scripts/forrt_contribs/tenzing.md content/contributors/tenzing.md
38+
if [ ! -f content/contributors/tenzing.md ]; then
39+
echo "tenzing.md not found"
40+
exit 1
41+
fi
42+
43+
- name: Validate curated resources
44+
run: |
45+
for file in content/curated_resources/*; do
46+
if [ ! -f "$file" ]; then
47+
echo "Non-markdown file found: $file"
48+
exit 1
49+
fi
50+
done
51+
52+
- name: Download GA Data
53+
env:
54+
GA_API_CREDENTIALS: ${{ secrets.GA_API_CREDENTIALS }}
55+
GA_PROPERTY_ID: ${{ secrets.GA_PROPERTY_ID }}
56+
run: python scripts/download_ga_data.py
57+
58+
- name: Upload data artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: data-artifact
62+
path: |
63+
content/contributors/tenzing.md
64+
content/curated_resources/
65+
data/ # GA data
66+
retention-days: 1

.github/workflows/deploy.yaml

+31-65
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: deploy
22

3-
# Build and deploy the website
4-
# Contains Tenzing's script to update the contributors list
5-
# Contains a script to update the curated resources list
6-
73
on:
84
push:
95
branches:
@@ -12,7 +8,7 @@ on:
128
branches:
139
- master
1410
schedule:
15-
- cron: '0 0 * * *' # Run daily at midnight
11+
- cron: '0 1 * * *' # 1 AM UTC (1 hour after data processing)
1612
workflow_dispatch:
1713

1814
jobs:
@@ -21,80 +17,52 @@ jobs:
2117
runs-on: ubuntu-22.04
2218
permissions:
2319
contents: read
24-
pull-requests: read
20+
actions: read # Needed for artifact access
2521
env:
2622
HUGO_VERSION: "0.123.3"
2723
HUGO_EXTENDED: true
28-
PYTHON_VERSION: "3.11"
2924
steps:
30-
- name: Checkout
25+
- name: Checkout repository
3126
uses: actions/checkout@v4
3227
with:
3328
ref: ${{ github.ref }}
3429
fetch-depth: 0
3530

36-
- name: Hugo - Setup
37-
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f
38-
with:
39-
hugo-version: ${{ env.HUGO_VERSION }}
40-
extended: ${{ env.HUGO_EXTENDED }}
41-
42-
- name: Python - Setup
43-
uses: actions/setup-python@v5
44-
with:
45-
python-version: ${{ env.PYTHON_VERSION }}
46-
cache: 'pip'
47-
48-
- name: Cache - Pip Dependencies
49-
id: pip-cache
50-
uses: actions/cache@v4
31+
- name: Try to download data artifact
32+
id: download-artifact
33+
uses: dawidd6/action-download-artifact@v2
34+
continue-on-error: true
5135
with:
52-
path: ~/.cache/pip
53-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
54-
restore-keys: |
55-
${{ runner.os }}-pip-
36+
workflow: data-processing.yml
37+
name: data-artifact
38+
path: .
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
5640

57-
- name: Python - Install dependencies
41+
- name: Run data processing if needed
42+
if: steps.download-artifact.outcome == 'failure'
43+
env:
44+
PYTHON_VERSION: "3.11"
5845
run: |
46+
# Install Python dependencies
5947
python3 -m pip install -r ./requirements.txt
60-
61-
- name: Python - Tenzing
62-
run: |
48+
49+
# Generate data files
6350
python3 scripts/forrt_contribs/tenzing.py
64-
65-
- name: Python - Curated Resources
66-
run: |
6751
python3 content/resources/resource.py
68-
69-
- name: Script - Move Tenzing's output and validate
70-
run: |
7152
mv scripts/forrt_contribs/tenzing.md content/contributors/tenzing.md
72-
73-
if [ ! -f content/contributors/tenzing.md ]; then
74-
echo "tenzing.md not found"
75-
exit 1
53+
54+
# Download GA data if possible
55+
if [ "${{ github.event_name }}" != 'pull_request' ]; then
56+
python scripts/download_ga_data.py
7657
fi
7758
78-
- name: Script - Validate curated resources
79-
run: |
80-
for file in content/curated_resources/*; do
81-
if [ ! -f "$file" ]; then
82-
echo "There is a non-markdown file ( $file ) in the curated resources folder. Exiting."
83-
exit 1
84-
fi
85-
done
86-
87-
NUM_FILES=$(ls -1 content/curated_resources/*.md | wc -l)
88-
echo "Number of curated resources: $NUM_FILES"
89-
90-
- name: Download GA Data
91-
if: ${{ github.event_name != 'pull_request' || github.event.inputs.GA_API_CREDENTIALS != '' }}
92-
env:
93-
GA_API_CREDENTIALS: ${{ secrets.GA_API_CREDENTIALS }}
94-
GA_PROPERTY_ID: ${{ secrets.GA_PROPERTY_ID }}
95-
run: python scripts/download_ga_data.py
59+
- name: Setup Hugo
60+
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f
61+
with:
62+
hugo-version: ${{ env.HUGO_VERSION }}
63+
extended: ${{ env.HUGO_EXTENDED }}
9664

97-
- name: Hugo - Build
65+
- name: Build site
9866
run: |
9967
if [ "$BRANCH" != 'refs/heads/master' ]; then
10068
hugo --gc --minify --cleanDestinationDir --destination public --baseURL https://staging.forrt.org
@@ -104,15 +72,13 @@ jobs:
10472
env:
10573
BRANCH: ${{ github.ref }}
10674

107-
- name: Upload Artifact - Website
75+
- name: Upload site artifact
10876
uses: actions/upload-artifact@v4
109-
env:
110-
ARTIFACT_NAME: forrt-website-${{ github.run_number }}
11177
with:
112-
name: ${{ env.ARTIFACT_NAME }}
78+
name: forrt-website-${{ github.run_number }}
11379
path: public/
11480
retention-days: 1
115-
81+
11682
deploy-test:
11783
name: Deploy - Test
11884
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)