Skip to content

Commit

Permalink
updates to remote folder content
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkundan committed Apr 10, 2024
1 parent 6ef429d commit 62915e0
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 742 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/generate-remotefolder-list.yml
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
36 changes: 36 additions & 0 deletions .scripts/fetchFolders.js
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);
259 changes: 0 additions & 259 deletions doc-templates/doc_template-1.md

This file was deleted.

62 changes: 0 additions & 62 deletions doc-templates/readme_template.md

This file was deleted.

Loading

0 comments on commit 62915e0

Please sign in to comment.