diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdf0003b86c9..a7e4eb476afd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: push: branches: - main +if: false env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/course-schedule.yml b/.github/workflows/course-schedule.yml index c109f06d0bfa..0453d47f1b3a 100644 --- a/.github/workflows/course-schedule.yml +++ b/.github/workflows/course-schedule.yml @@ -9,6 +9,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: false steps: - name: Checkout @@ -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/github-script@v7.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var pr_number = 1856; // Number(fs.readFileSync('pr-number')); // XXX + var upstream = fs.readFileSync('upstream-schedule').toString(); + var schedule = "CHANGED\n" + fs.readFileSync('upstream-schedule').toString(); // XXX + 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("")); + 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, + }); + }