-
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) · 3.2 KB
/
sync_checks.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
name: Sync and update Compliance Checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# schedule:
# - cron: "0 0 * * *" # Runs daily at midnight UTC
# workflow_dispatch: # Allows manual triggering
permissions:
# We will create a pull request, so we need write permissions
pull-requests: write
jobs:
sync-and-update:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17.2
env:
POSTGRES_DB: dashboard
POSTGRES_USER: openjs
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U openjs"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
# Checkout the current repository
- name: Checkout Repository
uses: actions/checkout@v4
# Create or switch to the chore/update-content branch
- name: Create or Checkout Branch
run: |
git fetch origin chore/update-content || true
git checkout chore/update-content || git checkout -b chore/update-content
# Clone the public repository and set it up
- name: Clone OpenJS Foundation Dashboard
run: |
git clone https://github.com/secure-dashboards/openjs-foundation-dashboard.git temp-openjs-dashboard
cd temp-openjs-dashboard
npm install
npm run db:migrate
psql -U openjs -d dashboard -c "\copy (SELECT json_agg(t) FROM compliance_checks t) TO '../data/checks.json'"
cd ..
rm -rf temp-openjs-dashboard
env:
PGHOST: localhost
PGUSER: openjs
PGPASSWORD: password
PGDATABASE: dashboard
# Commit the updated checks.json
- name: Commit Updated Checks
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add data/checks.json
git diff --cached --quiet || git commit -m "chore: sync with OpenJS Foundation Dashboard"
# Install dependencies for the current repository and generate site
- name: Install Dependencies and Generate Site
run: |
npm install
npm run populate-details
npm run populate-implementations
# Commit the generated site
- name: Commit and Push Changes
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add .
git diff --cached --quiet || git commit -m "chore: auto-update details and implementations"
git push origin chore/update-content
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create Pull Request
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: chore/update-content
commit-message: "chore: update generated site"
title: "Auto update content"
body: |
This PR contains the latest changes from the OpenJS Foundation Dashboard and updates the site content.
assignees: ${{ github.actor }}
delete-branch: true
token: ${{ secrets.GITHUB_TOKEN }}
base: main