-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add resource workflow + page #241
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8af7d7f
Add resource collection script
chartgerink be43b96
Add custom listing for the resources page
chartgerink ec2ed27
Init resources.qmd
chartgerink 30db9eb
Update navigation bar
chartgerink 2201c2a
Init workflow for resource collection
chartgerink fb81cc0
Update for pr
chartgerink 221134b
Update link to GH Discussion URL
chartgerink 0c14555
Move presentations back into main bar
chartgerink 1a463af
Add initial set of resources
chartgerink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,31 @@ | ||
name: Update resource page | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 8 * * *' | ||
|
||
jobs: | ||
run-r-script: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
# This helps override the branch protection later | ||
token: ${{ secrets.SUDO_GITHUB_TOKEN }} | ||
- name: Collect resource data | ||
run: node _scripts/resource-retrieval-graphql Resources | ||
- name: Re-render resource page | ||
run: quarto render resource.qmd | ||
- uses: EndBug/add-and-commit@v9 | ||
with: | ||
author_name: epiverse-trace-bot | ||
author_email: epiverse-trace-bot@users.noreply.github.com | ||
message: "Update `./resources/`" | ||
add: './resources/' |
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
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,100 @@ | ||
const fs = require("fs"); | ||
|
||
// PAT only needs access to read issues | ||
const pat = process.env.GITHUB_TOKEN; | ||
|
||
const arg = process.argv[2]; | ||
// Default to the announcements category | ||
const category = arg ? arg : "Announcements"; | ||
|
||
async function fetchDiscussions(afterCursor) { | ||
const query = ` | ||
{ | ||
repository(owner: "epiverse-trace", name: "epiverse-trace.github.io") { | ||
discussions(first: 100, after: ${afterCursor ? '"' + afterCursor + '"' : null}, orderBy: {field: CREATED_AT, direction: DESC}) { | ||
nodes { | ||
id | ||
title | ||
url | ||
createdAt | ||
labels(first: 10) { | ||
nodes { | ||
name | ||
} | ||
} | ||
author { | ||
login | ||
} | ||
category { | ||
name | ||
} | ||
upvoteCount | ||
} | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await fetch("https://api.github.com/graphql", { | ||
method: "POST", | ||
headers: { | ||
Authorization: `bearer ${pat}`, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ query }), | ||
}); | ||
|
||
const json = await response.json(); | ||
const discussions = json.data.repository.discussions.nodes; | ||
const { endCursor, hasNextPage } = json.data.repository.discussions.pageInfo; | ||
|
||
if (hasNextPage) { | ||
return discussions.concat(await fetchDiscussions(endCursor)); | ||
} else { | ||
return discussions; | ||
} | ||
} | ||
|
||
// When there are no next pages, process the responses | ||
fetchDiscussions(null).then((discussions) => { | ||
let filteredDiscussions = discussions.filter( | ||
(discussion) => discussion.category.name === category, | ||
); | ||
|
||
// Prepare the array for processing | ||
filteredDiscussions = filteredDiscussions.map((discussion) => ({ | ||
...discussion, | ||
author: discussion.author.login, | ||
category: discussion.category.name, | ||
labels: discussion.labels.nodes.map((label) => label.name).join(", "), | ||
})); | ||
|
||
// Ensure directory exists | ||
try { | ||
fs.mkdirSync('resources/'); | ||
} catch { | ||
console.log('resources/ already exists') | ||
} | ||
|
||
filteredDiscussions.forEach((discussion) => { | ||
fs.writeFile( | ||
`resources/${discussion.id}.qmd`, | ||
`--- | ||
title: "${discussion.title.replace(/"/g, '')}" | ||
url: "${discussion.url}" | ||
date: "${discussion.createdAt.substr(0,10)}" | ||
author: ${discussion.author} | ||
categories: [${discussion.labels}] | ||
upvotes: ${discussion.upvoteCount} | ||
---`, | ||
(err) => { | ||
if (err) throw err; | ||
console.log(`resources/${discussion.id}.qmd saved`); | ||
}, | ||
); | ||
}); | ||
}); |
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,29 @@ | ||
```{=html} | ||
<div class="archive list"> | ||
<% for (const item of items) { %> | ||
<div class="quarto-post image-right" <%= metadataAttrs(item) %>> | ||
<div class="body"> | ||
<h3 class="no-anchor listing-title"><a href="<%- item.url %>" class="no-external"><%= item.title %></a></h3> | ||
<div class="listing-subtitle"><a href="<%- item.url %>" class="no-external"><%= item.subtitle %></a></div> | ||
</div> | ||
<div class="metadata"> | ||
<div class="ratings"> | ||
<span class="rating listing-upvotes rating-upvotes-<%= item.upvotes %> ">👍 <%= item.upvotes %></span> | ||
</div> | ||
<% if (item.categories) { %> | ||
<span class="listing-categories"> | ||
<% for (const category of item.categories) { %> | ||
<span class="listing-category" onclick="window.quartoListingCategory('<%=category%>'); return false;"><%= category %></span> | ||
<% } %> | ||
</span> | ||
<% } %> | ||
<span class="archive-item-date"> | ||
<span class="listing-date"> | ||
<%= item.date %> | ||
</span> | ||
</span> | ||
</div> | ||
</div> | ||
<% } %> | ||
</div> | ||
``` |
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,21 @@ | ||
--- | ||
title: "Resources" | ||
listing: | ||
contents: resources | ||
sort: | ||
- "upvotes desc" | ||
type: default | ||
categories: true | ||
filter-ui: true | ||
sort-ui: | ||
- date | ||
- upvotes | ||
template: custom_listing_resources.ejs | ||
field-types: | ||
upvotes: number | ||
page-layout: full | ||
title-block-banner: true | ||
comments: false | ||
--- | ||
|
||
On this page, you can find resources shared on our discussion forum. [Submit your own](https://github.com/orgs/epiverse-trace/discussions/new?category=resources) and upvote the ones you like on GtiHub! |
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,8 @@ | ||
--- | ||
title: "How to Run GitHub Actions Locally Using the act CLI Tool" | ||
url: "https://github.com/orgs/epiverse-trace/discussions/245" | ||
date: "2024-05-06" | ||
author: chartgerink | ||
categories: [] | ||
upvotes: 1 | ||
--- |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be something like "all blog posts" or something? Because it doesn't include presentations, i.e., not all publications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the confusion - I moved the presentations back into the main bar for now and will come with a proposal. May also be helped by the multi-selection you mentioned (which is tracked over in #244).