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

Commit 36a148a

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

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/sync_checks.yml

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

0 commit comments

Comments
 (0)