From 63cb2ab59443e3a8240aac82335c0449e53fd414 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Wed, 29 May 2024 19:32:20 +0000 Subject: [PATCH] Trigger autograding with repository_dispatch --- .github/workflows/0-welcome.yml | 15 +++++++++++++++ .github/workflows/1-create-a-branch.yml | 15 +++++++++++++++ .github/workflows/2-commit-a-file.yml | 15 +++++++++++++++ .github/workflows/3-open-a-pull-request.yml | 15 +++++++++++++++ .github/workflows/4-merge-your-pull-request.yml | 15 +++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/.github/workflows/0-welcome.yml b/.github/workflows/0-welcome.yml index 3cb9d86..31ad62c 100644 --- a/.github/workflows/0-welcome.yml +++ b/.github/workflows/0-welcome.yml @@ -64,3 +64,18 @@ jobs: branch_name: my-first-branch env: GITHUB_TOKEN: ${{ secrets.GLOBAL_CLASSROOM_ORG_TOKEN }} + + # Commits pushed by an Action will not create a new workflow run. To work + # around this, create a repository_dispatch event to ensure that GitHub + # Classroom's autograding workflow runs on the commit created by + # skills/action-update-step. + # Reference: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + - name: Trigger autograding workflow + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/dispatches" \ + -f "event_type=autograde" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/1-create-a-branch.yml b/.github/workflows/1-create-a-branch.yml index ffcf5f3..de39462 100644 --- a/.github/workflows/1-create-a-branch.yml +++ b/.github/workflows/1-create-a-branch.yml @@ -64,3 +64,18 @@ jobs: from_step: 1 to_step: 2 branch_name: my-first-branch + + # Commits pushed by an Action will not create a new workflow run. To work + # around this, create a repository_dispatch event to ensure that GitHub + # Classroom's autograding workflow runs on the commit created by + # skills/action-update-step. + # Reference: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + - name: Trigger autograding workflow + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/dispatches" \ + -f "event_type=autograde" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/2-commit-a-file.yml b/.github/workflows/2-commit-a-file.yml index c4d219a..bbb7912 100644 --- a/.github/workflows/2-commit-a-file.yml +++ b/.github/workflows/2-commit-a-file.yml @@ -62,3 +62,18 @@ jobs: from_step: 2 to_step: 3 branch_name: my-first-branch + + # Commits pushed by an Action will not create a new workflow run. To work + # around this, create a repository_dispatch event to ensure that GitHub + # Classroom's autograding workflow runs on the commit created by + # skills/action-update-step. + # Reference: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + - name: Trigger autograding workflow + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/dispatches" \ + -f "event_type=autograde" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/3-open-a-pull-request.yml b/.github/workflows/3-open-a-pull-request.yml index f3f0a40..31cca1a 100644 --- a/.github/workflows/3-open-a-pull-request.yml +++ b/.github/workflows/3-open-a-pull-request.yml @@ -66,3 +66,18 @@ jobs: from_step: 3 to_step: 4 branch_name: my-first-branch + + # Commits pushed by an Action will not create a new workflow run. To work + # around this, create a repository_dispatch event to ensure that GitHub + # Classroom's autograding workflow runs on the commit created by + # skills/action-update-step. + # Reference: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + - name: Trigger autograding workflow + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/dispatches" \ + -f "event_type=autograde" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-merge-your-pull-request.yml b/.github/workflows/4-merge-your-pull-request.yml index 47b856c..e2463fa 100644 --- a/.github/workflows/4-merge-your-pull-request.yml +++ b/.github/workflows/4-merge-your-pull-request.yml @@ -62,3 +62,18 @@ jobs: from_step: 4 to_step: X branch_name: my-first-branch + + # Commits pushed by an Action will not create a new workflow run. To work + # around this, create a repository_dispatch event to ensure that GitHub + # Classroom's autograding workflow runs on the commit created by + # skills/action-update-step. + # Reference: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow + - name: Trigger autograding workflow + run: | + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/dispatches" \ + -f "event_type=autograde" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}