Repository navigation
57 lines (52 loc) · 1.77 KB
/
Copy pathdata-sync.yml
File metadata and controls
57 lines (52 loc) · 1.77 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
name: data-sync
on:
schedule:
- cron: "17 */6 * * *"
workflow_dispatch:
concurrency:
group: data-sync
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
environment: production
defaults:
run:
working-directory: apps/api
env:
DATABASE_URL: ${{ secrets.PRODUCTION_DATABASE_URL }}
steps:
- name: Require the database secret
run: |
if [ -z "$DATABASE_URL" ]; then
echo "::error::Add the PRODUCTION_DATABASE_URL secret"
exit 1
fi
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- run: uv sync --frozen
- name: Mask the connection details
run: >
uv run python -c "import os;
from hackproof.db_utils.connection import Connection;
print('\n'.join(Connection.from_url(os.environ['DATABASE_URL']).mask_lines()))"
- name: Regenerate the data files from the database
run: uv run hackproof export
- uses: peter-evans/create-pull-request@v7
with:
branch: chore/sync-data
delete-branch: true
commit-message: "fix: sync the data files with the database"
title: "fix: sync the data files with the database"
body: |
The database and the committed data files had drifted apart. This regenerates the files from the database so they match again.
- the files are rewritten by `hackproof export`, the same command that produced them
- review the diff, then merge to bring the repo back in sync
- this branch is refreshed on every scheduled run until it is merged
labels: data
add-paths: data/**