-
Notifications
You must be signed in to change notification settings - Fork 3
86 lines (80 loc) · 3.17 KB
/
regenerate-data-from-cache.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Ensure everything builds
on:
push:
schedule:
- cron: "30 13 * * *"
jobs:
regenerate-data:
name: Regenerate data from cache
runs-on: ubuntu-latest
steps:
- name: Checkout active ref on run not triggered by a schedule
uses: actions/checkout@v3
if: ${{ github.event_name != 'schedule' }}
- name: Checkout 'master' on scheduled run
uses: actions/checkout@v3
if: ${{ github.event_name == 'schedule' }}
with:
ref: "master"
- uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install requests
- working-directory: src/data
run: python ../scripts/musicAndQuestsFromCache.py write
- name: Print `git status`
run: "git status --porcelain"
- name: Ensure working directory clean (unless run triggered by a schedule)
if: ${{ github.event_name != 'schedule' }}
run: 'if [ ! -z "$(git status --porcelain)" ]; then echo "Status is unclean, and this is not a scheduled run."; git status --porcelain; exit 1; fi'
# Create pull request if this job was triggered by a schedule
- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v5
if: ${{ github.event_name == 'schedule' }}
with:
base: master
title: "[auto] Rebuild data from the latest cache"
body: |
Rebuild data from the latest cache.
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
labels: |
automated-pull-request
- name: Check outputs
if: ${{ steps.create-pull-request.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.create-pull-request.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pull-request.outputs.pull-request-url }}"
build-server:
name: Ensure server compiles
runs-on: ubuntu-latest
steps:
- name: Checkout active ref on run not triggered by a schedule
uses: actions/checkout@v3
if: ${{ github.event_name != 'schedule' }}
- name: Checkout 'master' on scheduled run
uses: actions/checkout@v3
if: ${{ github.event_name == 'schedule' }}
with:
ref: "master"
- uses: actions/setup-node@v3
with:
node-version: '22.x'
cache: 'yarn'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
run: yarn
- name: Ensure server compiles
run: yarn run typeCheckAndDoNotRun