-
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (98 loc) · 3.28 KB
/
sync_data.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Sync checks and policies
on:
# Manually trigger the workflow
workflow_dispatch:
permissions:
# We will create a pull request, so we need write permissions
pull-requests: write
# We will be committing to the repository, so we need write permissions
contents: write
jobs:
sync-and-update:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17.2
env:
POSTGRES_DB: dashboard
POSTGRES_USER: visionBoard
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U visionBoard"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create or Checkout Branch (chore/update-content)
run: |
git fetch origin chore/update-content || true
git checkout chore/update-content || git checkout -b chore/update-content
- name: Clone visionBoard and import checks
run: |
git clone https://github.com/OpenPathfinder/visionBoard.git temp-visionBoard
cd temp-visionBoard
npm install
npm run db:migrate
mkdir -p output
npm run db:export-checks
cp output/checks.json ../data/checks.json
cd ..
rm -rf temp-visionBoard
env:
PGHOST: localhost
PGUSER: visionBoard
PGPASSWORD: password
PGDATABASE: dashboard
- name: Debug Git Changes
run: |
git status
git diff
- name: Commit Updated Checks
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add -A
git diff --cached --quiet || git commit -m "chore: sync with visionBoard Checks"
- name: Clone fortSphere and import policies
run: |
git clone https://github.com/OpenPathfinder/fortSphere.git temp-fortSphere
cd temp-fortSphere
npm install
mkdir -p output
npm run export-policies
cp output/policies.json ../data/policies.json
cd ..
rm -rf temp-fortSphere
- name: Install Dependencies and update dynamic content
run: |
npm install
npm run populate-checks
npm run populate-policies
- name: Debug Git Changes
run: |
git status
git diff
- name: Commit and Push Changes
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add -A
git diff --cached --quiet || git commit -m "chore: auto-update content"
git push origin chore/update-content
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create and Assign Pull Request
run: |
gh pr create \
--base main \
--head chore/update-content \
--title "[AUTO] Sync with dashboard database" \
--body "This PR updates the content based on the current state of the Dashboard." \
--assignee "${{ github.actor }}" \
--reviewer "${{ github.actor }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}