libscie / .github

Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Add an auto-updating content calendar #2

Open chartgerink opened 4 months ago

chartgerink commented 4 months ago

We started using GitHub projects recently to help consolidate some of our data collection and make GitHub more of a place of consensus. See for example our recent community events calendar or our ResearchEquals User Stories project.

We are looking to add a project that keeps track of content we produce, so that we can more easily assess our activity throughout the internet. The goal is to provide a consolidated history of our activity, that we can forget about until we need it.

It appears that we can do this through API queries, utilizing the new GraphQL endpoint. In NodeJS, it would look something like this (based off of these docs):

const fetch = require('node-fetch');

const token = 'token'; // Replace with your GitHub token
const url = 'https://api.github.com/graphql';

const query = `
{
  viewer {
    login
    email
  }
}
`;

const mutation = `
mutation {
    addProjectV2DraftIssue(input: {projectId: "PROJECT_ID" title: "TITLE" body: "BODY"}) {
      projectItem {
        id
      }
    }
  }
`;

const options = {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ query })
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(JSON.stringify(data, null, 2)))
  .catch(error => console.error('Error:', error));

We could integrate this with various of our data sources in Pipedream, a service we use for our automations. Our data sources could include: