diff --git a/.github/ISSUE_TEMPLATE/workflows/commit-meeting-summaries.yml b/.github/ISSUE_TEMPLATE/workflows/commit-meeting-summaries.yml new file mode 100644 index 0000000..d7b915a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/workflows/commit-meeting-summaries.yml @@ -0,0 +1,33 @@ +# .github/workflows/commit-meeting-summaries.yml +name: Commit Meeting Summaries + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' # Run daily at midnight + +jobs: + commit-meeting-summaries: + runs-on: ubuntu-latest + + steps: + - name: Retrieve Meeting Summaries + id: retrieve-summaries + run: | + curl -X POST ${{ secrets.NETLIFY_BASE_URL }}/.netlify/functions/getMeetingSummaries \ + -H 'Content-Type: application/json' \ + -d '{}' \ + -o meeting-summaries.json + echo "::set-output name=summaries::$(cat meeting-summaries.json)" + + - name: Commit to GitHub + run: | + curl -X POST ${{ secrets.NETLIFY_BASE_URL }}/.netlify/functions/commitToGitHub \ + -H 'Content-Type: application/json' \ + -d '{ + "owner": "SingularityNET-Archive", + "repo": "SingularityNET-Archive", + "filePath": "Data/meeting-summaries.json", + "content": ${{ steps.retrieve-summaries.outputs.summaries }}, + "commitMessage": "Update meeting summaries" + }' \ No newline at end of file diff --git a/netlify/functions/commitToGitHub.js b/netlify/functions/commitToGitHub.js new file mode 100644 index 0000000..710be0a --- /dev/null +++ b/netlify/functions/commitToGitHub.js @@ -0,0 +1,31 @@ +// netlify/functions/commitToGitHub.js +import { Octokit } from "@octokit/rest"; + +export const handler = async (event, context) => { + try { + const { owner, repo, filePath, content, commitMessage } = JSON.parse(event.body); + + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + }); + + const { data } = await octokit.repos.createOrUpdateFileContents({ + owner, + repo, + path: filePath, + message: commitMessage, + content: Buffer.from(JSON.stringify(content, null, 2)).toString('base64'), + }); + + return { + statusCode: 200, + body: JSON.stringify({ message: 'Data committed to GitHub successfully' }), + }; + } catch (error) { + console.error('Error in commitToGitHub function:', error); + return { + statusCode: 500, + body: JSON.stringify({ error: 'Failed to commit data to GitHub' }), + }; + } +}; \ No newline at end of file diff --git a/netlify/functions/getMeetingSummaries.js b/netlify/functions/getMeetingSummaries.js new file mode 100644 index 0000000..5028f1f --- /dev/null +++ b/netlify/functions/getMeetingSummaries.js @@ -0,0 +1,29 @@ +// netlify/functions/getMeetingSummaries.js +import { supabase } from '../../lib/supabaseClient'; + +export const handler = async (event, context) => { + try { + const { data, error } = await supabase + .from('meetingsummaries') + .select('summary'); + + if (error) { + console.error('Error retrieving meeting summaries:', error); + return { + statusCode: 500, + body: JSON.stringify({ error: 'Failed to retrieve meeting summaries' }), + }; + } + + return { + statusCode: 200, + body: JSON.stringify(data), + }; + } catch (error) { + console.error('Error in getMeetingSummaries function:', error); + return { + statusCode: 500, + body: JSON.stringify({ error: 'Internal server error' }), + }; + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b65319d..076c185 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1893,13 +1893,14 @@ } }, "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "hasInstallScript": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" }, "engines": { @@ -2277,6 +2278,25 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esniff/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", @@ -2331,6 +2351,15 @@ "node": ">=0.10.0" } }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -2467,9 +2496,9 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual",