-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
103 additions
and
742 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Generate Folder List | ||
|
||
on: | ||
schedule: | ||
- cron: '*/5 * * * *' # Runs at every 5th minute | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
generate-and-commit-folder-list: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' # Use the Node.js version that matches your project requirements | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run the script to fetch folders and generate the .tsx file | ||
run: node .scripts/fetchFolders.js | ||
|
||
- name: Commit and push changes if there are any | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Your Name" | ||
git add static/folderList.json | ||
git commit -m "Automatically update folder list" -a || echo "No changes to commit" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const fs = require('fs'); | ||
const fetch = require('node-fetch'); | ||
|
||
const GITHUB_API_URL = 'https://api.github.com/repos'; | ||
const REPO_OWNER = 'saviynt'; | ||
const REPO_NAME = 'community-connectors'; | ||
const BRANCH = 'main'; | ||
// const TOKEN = 'your_github_token'; | ||
|
||
// const headers = { | ||
// 'Authorization': `token ${TOKEN}` | ||
// }; | ||
|
||
async function fetchFolders() { | ||
const url = `${GITHUB_API_URL}/${REPO_OWNER}/${REPO_NAME}/contents?ref=${BRANCH}`; | ||
const response = await fetch(url, { headers }); | ||
const data = await response.json(); | ||
|
||
const directories = data.filter(item => item.type === 'dir').map(dir => ({ | ||
name: dir.name, | ||
readmeLink: `https://github.com/${REPO_OWNER}/${REPO_NAME}/blob/${BRANCH}/${dir.name}/README.md`, | ||
srcLink: `https://github.com/${REPO_OWNER}/${REPO_NAME}/tree/${BRANCH}/${dir.name}/src`, | ||
docsLink: `https://github.com/${REPO_OWNER}/${REPO_NAME}/tree/${BRANCH}/${dir.name}/docs`, | ||
distLink: `https://github.com/${REPO_OWNER}/${REPO_NAME}/tree/${BRANCH}/${dir.name}/dist`, | ||
})); | ||
|
||
generateJSONFile(directories); | ||
} | ||
|
||
function generateJSONFile(folders) { | ||
const content = JSON.stringify(folders, null, 2); | ||
fs.writeFileSync('static/folderList.json', content); | ||
console.log('folderList.json has been created/updated'); | ||
} | ||
|
||
fetchFolders().catch(console.error); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.