Skip to content

Commit 605bbb3

Browse files
authored
Added two workflows for fetching contributor and project roadmap data (#781)
* github-actions : added sync.contributors.yml * github-actions : Added sync-project-roadmap.yml
1 parent e9d84d0 commit 605bbb3

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name : Sync Contributors Data
2+
3+
on:
4+
schedule: # Run sunday at midnight every week
5+
- cron: '0 0 * * 0'
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync-contributors-data:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Get Token
16+
uses: actions/create-github-app-token@v1
17+
id: get_workflow_token
18+
with:
19+
app-id: ${{ vars.APP_ID }}
20+
private-key: ${{ secrets.PRIVATE_KEY }}
21+
22+
- name: Fetch Contributors data
23+
uses: actions/github-script@v7
24+
env:
25+
ORGS: ${{ github.repository_owner }}
26+
REPO: ${{ github.event.repository.name }}
27+
with:
28+
github-token: ${{ steps.get_workflow_token.outputs.token }}
29+
script: |
30+
const fs = require('fs');
31+
32+
let data = await github.paginate(github.rest.repos.listContributors, {
33+
owner: process.env.ORGS,
34+
repo: process.env.REPO,
35+
per_page: 100,
36+
headers: {
37+
"X-GitHub-Api-Version": "2022-11-28",
38+
},
39+
});
40+
41+
// Filter the data to get only the required fields
42+
data = data.map(({ login, id, avatar_url, html_url }) =>
43+
({ login, id, avatar_url, html_url }));
44+
45+
// Store the data in a file
46+
fs.writeFileSync('community.json', JSON.stringify(data, null, 2));
47+
48+
- name: Commit changes
49+
env:
50+
GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
51+
run: |
52+
git config user.name "the-json-schema-bot[bot]"
53+
git config user.email "the-json-schema-bot[bot]@users.noreply.github.com"
54+
git add community.json
55+
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(community): update community.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/})
56+
57+
58+
59+
+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name : Sync Project Roadmap Data
2+
3+
on:
4+
schedule: # Run sundat at 00:05 every week
5+
- cron: '5 0 * * 0'
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync-roadmap-data:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Get Token
16+
uses: actions/create-github-app-token@v1
17+
id: get_workflow_token
18+
with:
19+
app-id: ${{ vars.APP_ID }}
20+
private-key: ${{ secrets.PRIVATE_KEY }}
21+
22+
# fetch project data and store it in a file
23+
- name: Fetch project data
24+
env:
25+
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }} # GitHub App token stored in secrets
26+
PROJECT_ID: ${{vars.ROADMAP_PROJECT_ID}} # Project ID
27+
run: |
28+
gh api graphql -f query='
29+
query($PROJECT_ID : ID!) {
30+
node(id: $PROJECT_ID) {
31+
... on ProjectV2 {
32+
items(first: 20) {
33+
nodes {
34+
id
35+
fieldValues(first: 8) {
36+
nodes {
37+
... on ProjectV2ItemFieldTextValue {
38+
text
39+
field {
40+
... on ProjectV2FieldCommon {
41+
name
42+
}
43+
}
44+
}
45+
... on ProjectV2ItemFieldDateValue {
46+
date
47+
field {
48+
... on ProjectV2FieldCommon {
49+
name
50+
}
51+
}
52+
}
53+
... on ProjectV2ItemFieldSingleSelectValue {
54+
name
55+
field {
56+
... on ProjectV2FieldCommon {
57+
name
58+
}
59+
}
60+
}
61+
}
62+
}
63+
content {
64+
... on DraftIssue {
65+
title
66+
body
67+
}
68+
... on Issue {
69+
title
70+
assignees(first: 10) {
71+
nodes {
72+
login
73+
}
74+
}
75+
}
76+
... on PullRequest {
77+
title
78+
assignees(first: 10) {
79+
nodes {
80+
login
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}
88+
}
89+
}' -f PROJECT_ID=$PROJECT_ID | jq '.data.node.items.nodes' > project_data.json
90+
91+
# commit updated project data
92+
- name: Commit changes
93+
env:
94+
GITHUB_APP_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
95+
run: |
96+
git config user.name "the-json-schema-bot[bot]"
97+
git config user.email "the-json-schema-bot[bot]@users.noreply.github.com"
98+
git add project_data.json
99+
git diff --quiet && git diff --staged --quiet || (git commit -m "chore(project_data): update project_data.json" && git push "https://x-access-token:${GITHUB_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF#refs/heads/})
100+

0 commit comments

Comments
 (0)