-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 1.79 KB
/
update-data.yml
File metadata and controls
63 lines (54 loc) · 1.79 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Update PER Data
on:
schedule:
# Runs at 00:00 UTC every day
- cron: '0 0 * * *'
workflow_dispatch: # Allows manual trigger
jobs:
update-data:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}
persist-credentials: true
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Fetch and process data
run: |
npm run update-data
env:
# Add any required API keys or environment variables here
NODE_ENV: production
- name: Check for changes
id: check_changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit changes if they exist
if: steps.check_changes.outputs.changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
CURRENT_DATE=$(date -u +"%Y-%m-%d")
LAST_UPDATE=$(jq -r '.lastUpdate' data/last-update.json)
git add data/
git commit -m "Update PER data: ${CURRENT_DATE}" -m "Last data update: ${LAST_UPDATE}"
- name: Push changes
if: steps.check_changes.outputs.changes == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: main
force: true