Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Feb 28, 2024
1 parent 45ee988 commit 5c9b8c6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
if: false

env:
CARGO_TERM_COLOR: always
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/course-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: false

steps:
- name: Checkout
Expand All @@ -33,3 +34,58 @@ jobs:
with:
name: course-schedule
path: course-schedule/
upload:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Setup Rust cache"
uses: ./.github/workflows/setup-rust-cache

- name: "Generate Schedule on upstream branch"
run: |
cargo run -p mdbook-course --bin course-schedule > upstream-schedule
- name: "Comment on PR if schedules differ"
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var pr_number = Number(fs.readFileSync('pr-number'));
var upstream = fs.readFileSync('upstream-schedule').toString();
var schedule = "CHANGED\n" + fs.readFileSync('upstream-schedule').toString();
schedule = "<!-- course-schedule -->\n" +
"# Changes to Course Schedule\n" +
"This PR changes the course schedule. The new schedule is shown below.\n\n" +
schedule;
// Look for existing comments
var existing_comment;
for await ({ data: comments } of github.paginate.iterator(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number
})) {
existing_comment = comments.find((c) => c.body.includes("<!-- course-schedule -->"));
if (existing_comment) {
break;
}
}
if (existing_comment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing_comment.id,
body: schedule,
});
} else if (upstream != schedule) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
body: schedule,
});
}

0 comments on commit 5c9b8c6

Please sign in to comment.