-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (51 loc) · 1.55 KB
/
getGitHubRepos.yaml
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
name: Get GitHub Repos
on:
# cronjob trigger
schedule:
- cron: "0 0 * * *"
# manual trigger
workflow_dispatch:
jobs:
get-github-repos:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get Repository Data
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
var fs = require('fs')
const query = `query($org:String!) {
organization(login: $org) {
repositories(first: 100) {
nodes {
name
description
homepageUrl
repositoryTopics(first: 5) {
nodes {
topic {
name
}
}
}
}
}
}
}`;
const variables = {
org: 'ibm-client-engineering'
}
const result = await github.graphql(query, variables)
// Export data to JSON file
fs.writeFileSync('repoData.json', JSON.stringify(result, null, 2));
- name: Commit and push JSON file
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add repoData.json
git commit -m "Add repository data JSON file"
git push