Skip to content

Commit 5e34b45

Browse files
committed
Restrict data update workflows to main branch
1 parent 9c368d9 commit 5e34b45

2 files changed

Lines changed: 71 additions & 69 deletions

File tree

.github/workflows/cache.yml

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
name: Routine Data Cache Request
2-
3-
on:
4-
workflow_dispatch:
5-
schedule:
6-
- cron: '45 8 * * *'
7-
8-
concurrency:
9-
group: data-cache
10-
11-
defaults:
12-
run:
13-
shell: bash
14-
15-
env:
16-
TAG: CACHE
17-
18-
jobs:
19-
runDataUpdate:
20-
name: Run Cache Request
21-
runs-on: ubuntu-latest
22-
env:
23-
REPO_DIR: main
24-
TIMESTAMP: X
25-
steps:
26-
- name: Store timestamp
27-
run: |
28-
echo "TIMESTAMP=$(date -u +"%F-%H")" >> "$GITHUB_ENV"
29-
30-
- name: Checkout
31-
uses: actions/checkout@v6
32-
with:
33-
path: ${{ env.REPO_DIR }}
34-
token: ${{ secrets.GITHUB_TOKEN }}
35-
36-
- name: Setup python
37-
uses: actions/setup-python@v6
38-
with:
39-
python-version: '3.11'
40-
cache: 'pip'
41-
cache-dependency-path: '${{ env.REPO_DIR }}/_visualize/scripts/requirements.txt'
42-
43-
- name: Install dependencies
44-
run: pip install -r $REPO_DIR/_visualize/scripts/requirements.txt
45-
46-
- name: Run data collection script
47-
run: |
48-
set -eu
49-
cd $REPO_DIR/_visualize/scripts
50-
./UPDATE.sh $TAG
51-
env:
52-
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53-
54-
- name: Show health stats
55-
if: ${{ always() }}
56-
run: |
57-
cat $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.txt || true
58-
echo "Warning Count: $(grep -c 'Warning' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
59-
echo "From Timeouts: $(grep -c 'but failed' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
60-
echo "Limit Reached: $(grep -c 'rate limit exceeded' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
61-
62-
- name: Save log files
63-
if: ${{ always() }}
64-
uses: actions/upload-artifact@v6
65-
with:
66-
name: logfiles_${{ env.TIMESTAMP }}_cache
67-
path: |
68-
${{ env.REPO_DIR }}/_visualize/LAST_${{ env.TAG }}_UPDATE.txt
69-
${{ env.REPO_DIR }}/_visualize/LAST_${{ env.TAG }}_UPDATE.log
1+
name: Routine Data Cache Request
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '45 8 * * *'
7+
8+
concurrency:
9+
group: data-cache
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
env:
16+
TAG: CACHE
17+
18+
jobs:
19+
runDataUpdate:
20+
if: github.ref == 'refs/heads/main'
21+
name: Run Cache Request
22+
runs-on: ubuntu-latest
23+
env:
24+
REPO_DIR: main
25+
TIMESTAMP: X
26+
steps:
27+
- name: Store timestamp
28+
run: |
29+
echo "TIMESTAMP=$(date -u +"%F-%H")" >> "$GITHUB_ENV"
30+
31+
- name: Checkout
32+
uses: actions/checkout@v6
33+
with:
34+
path: ${{ env.REPO_DIR }}
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Setup python
38+
uses: actions/setup-python@v6
39+
with:
40+
python-version: '3.11'
41+
cache: 'pip'
42+
cache-dependency-path: '${{ env.REPO_DIR }}/_visualize/scripts/requirements.txt'
43+
44+
- name: Install dependencies
45+
run: pip install -r $REPO_DIR/_visualize/scripts/requirements.txt
46+
47+
- name: Run data collection script
48+
run: |
49+
set -eu
50+
cd $REPO_DIR/_visualize/scripts
51+
./UPDATE.sh $TAG
52+
env:
53+
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Show health stats
56+
if: ${{ always() }}
57+
run: |
58+
cat $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.txt || true
59+
echo "Warning Count: $(grep -c 'Warning' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
60+
echo "From Timeouts: $(grep -c 'but failed' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
61+
echo "Limit Reached: $(grep -c 'rate limit exceeded' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
62+
63+
- name: Save log files
64+
if: ${{ always() }}
65+
uses: actions/upload-artifact@v6
66+
with:
67+
name: logfiles_${{ env.TIMESTAMP }}_cache
68+
path: |
69+
${{ env.REPO_DIR }}/_visualize/LAST_${{ env.TAG }}_UPDATE.txt
70+
${{ env.REPO_DIR }}/_visualize/LAST_${{ env.TAG }}_UPDATE.log

.github/workflows/update.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ defaults:
1515

1616
jobs:
1717
runDataUpdate:
18+
if: github.ref == 'refs/heads/main'
1819
name: Run Data Update
1920
runs-on: ubuntu-latest
2021
env:

0 commit comments

Comments
 (0)