Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 3628c97

Browse files
committed
feat: add pipeline to sync the checks from the dashboard db
1 parent b220e68 commit 3628c97

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/sync_checks.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Sync and update Compliance Checks
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
# schedule:
9+
# - cron: "0 0 * * *" # Runs daily at midnight UTC
10+
# workflow_dispatch: # Allows manual triggering
11+
12+
permissions:
13+
# We will create a pull request, so we need write permissions
14+
pull-requests: write
15+
16+
jobs:
17+
sync-and-update:
18+
runs-on: ubuntu-latest
19+
20+
services:
21+
postgres:
22+
image: postgres:17.2
23+
env:
24+
POSTGRES_DB: dashboard
25+
POSTGRES_USER: openjs
26+
POSTGRES_PASSWORD: password
27+
ports:
28+
- 5432:5432
29+
options: >-
30+
--health-cmd="pg_isready -U openjs"
31+
--health-interval=10s
32+
--health-timeout=5s
33+
--health-retries=5
34+
35+
steps:
36+
# Checkout the current repository
37+
- name: Checkout Repository
38+
uses: actions/checkout@v4
39+
40+
# Create or switch to the chore/update-content branch
41+
- name: Create or Checkout Branch
42+
run: |
43+
git fetch origin chore/update-content || true
44+
git checkout chore/update-content || git checkout -b chore/update-content
45+
46+
# Clone the public repository and set it up
47+
- name: Clone OpenJS Foundation Dashboard
48+
run: |
49+
git clone https://github.com/secure-dashboards/openjs-foundation-dashboard.git temp-openjs-dashboard
50+
cd temp-openjs-dashboard
51+
npm install
52+
npm run db:migrate
53+
psql -U openjs -d dashboard -c "\copy (SELECT json_agg(t) FROM compliance_checks t) TO '../data/checks.json'"
54+
cd ..
55+
rm -rf temp-openjs-dashboard
56+
env:
57+
PGHOST: localhost
58+
PGUSER: openjs
59+
PGPASSWORD: password
60+
PGDATABASE: dashboard
61+
62+
# Commit the updated checks.json
63+
- name: Commit Updated Checks
64+
run: |
65+
git config user.name "GitHub Actions"
66+
git config user.email "[email protected]"
67+
git add data/checks.json
68+
git diff --cached --quiet || git commit -m "chore: sync with OpenJS Foundation Dashboard"
69+
70+
# Install dependencies for the current repository and generate site
71+
- name: Install Dependencies and Generate Site
72+
run: |
73+
npm install
74+
npm run populate-details
75+
npm run populate-implementations
76+
77+
# Commit the generated site
78+
- name: Commit and Push Changes
79+
run: |
80+
git config user.name "GitHub Actions"
81+
git config user.email "[email protected]"
82+
git add .
83+
git diff --cached --quiet || git commit -m "chore: auto-update details and implementations"
84+
git push origin chore/update-content
85+
86+
# Create Pull Request
87+
- name: Create Pull Request
88+
uses: peter-evans/create-pull-request@v7
89+
with:
90+
branch: chore/update-content
91+
commit-message: "chore: update generated site"
92+
title: "Auto update content"
93+
body: |
94+
This PR contains the latest changes from the OpenJS Foundation Dashboard and updates the site content.

0 commit comments

Comments
 (0)