Skip to content

Get GitHub Repos

Get GitHub Repos #6

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