Skip to content

Commit 323c050

Browse files
feat: Migrate exercise to issue based flow (#270)
* Update README * Migrate the exercise to issue based flow * Minor wording tweaks * Add grading workflows and update theory * Updates to step 3 * Update exercise-toolkit references to v0.5.0 * Test run updates * Add screenshot to step1 * Test run updates * Update README * Wording adjustments and including links from test run * Add optional step about viewing actions logs * Update url for copy exercise --------- Co-authored-by: Christopher W. Blake <chriswblake@github.com>
1 parent 5aa61b4 commit 323c050

27 files changed

+907
-636
lines changed

.github/steps/-step.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/steps/0-welcome.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/steps/1-create-a-workflow.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/steps/1-step.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Step 1: Create a workflow file
2+
3+
### 📖 Theory: Introduction to workflows
4+
5+
A **workflow** is an automated process that you define in your repository. Workflows are described in YAML files stored in the `.github/workflows` directory. Each workflow is triggered by specific [events](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows) happening in your repository such as opening a pull request, pushing code, or creating an issue.
6+
7+
Workflows let you automate tasks like building, testing, or deploying your code, and can respond to almost any activity in your project.
8+
9+
> [!NOTE]
10+
> If you want to learn more check out these resources:
11+
> - [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)
12+
> - [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows)
13+
14+
### ⌨️ Activity: Create a workflow file
15+
16+
1. Open this repository in a new browser tab so you can work on the steps while you read the instructions in this tab.
17+
18+
1. In the **Code** tab of your repository, create a new branch named `welcome-workflow`.
19+
20+
<img width="400" alt="create branch screenshot" src="https://github.com/user-attachments/assets/8aa4a918-c877-4214-9efe-c9a99ca6421b" />
21+
22+
1. In the `welcome-workflow` branch, navigate to the `.github/workflows` directory.
23+
24+
1. Create a new file named `welcome.yml` in the `.github/workflows` directory with the following content:
25+
26+
```yaml
27+
name: Post welcome comment
28+
on:
29+
pull_request:
30+
types: [opened]
31+
permissions:
32+
pull-requests: write
33+
```
34+
35+
> [!NOTE]
36+
> This is an incomplete workflow file. It is normal if you receive an error message. One step at a time! 😎
37+
38+
1. Commit your changes directly to the `welcome-workflow` branch.
39+
40+
1. With your workflow file committed, Mona will check your work and prepare the next step in this exercise!
41+
42+
<details>
43+
<summary>Having trouble? 🤷</summary><br/>
44+
45+
- Make sure you are on the `welcome-workflow` branch when creating the workflow file.
46+
- Double-check the file path and YAML indentation.
47+
48+
</details>

.github/steps/2-add-a-job.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/steps/2-step.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Step 2: Add a job to your workflow file
2+
3+
Nice work! :tada: You added a workflow file!
4+
5+
### 📖 Theory: Introduction to jobs
6+
7+
A [job](https://docs.github.com/en/actions/about-github-actions/understanding-github-actions#jobs) is a group of steps that run together on the same [runner](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners) within a workflow. Each job is defined under the `jobs` section and runs independently and in parallel by default.
8+
9+
Jobs help you organize your workflow into logical units, such as building, testing, or deploying your code.
10+
11+
> [!Tip]
12+
> You can define a job to run with multiple [variations using a matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow).
13+
14+
### ⌨️ Activity: Add a job to your workflow file
15+
16+
1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.
17+
18+
1. Edit the file to add the `jobs` section and 1 job named `welcome`, which will run on the latest Ubuntu operating system.
19+
20+
```yaml
21+
name: Post welcome comment
22+
on:
23+
pull_request:
24+
types: [opened]
25+
permissions:
26+
pull-requests: write
27+
jobs:
28+
welcome:
29+
name: Post welcome comment
30+
runs-on: ubuntu-latest
31+
```
32+
33+
1. Commit your changes to the `welcome-workflow` branch.
34+
35+
1. With the job information added, Mona will review your work and prepare the next step in this exercise!
36+
37+
<details>
38+
<summary>Having trouble? 🤷</summary><br/>
39+
40+
- Make sure the `jobs` section is properly indented in your YAML file.
41+
- Confirm you are editing the correct file and branch.
42+
43+
</details>

.github/steps/3-add-actions.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/steps/3-step.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Step 3: Add a step to your workflow file
2+
3+
_Nice work adding a job to your workflow! :dancer:_
4+
5+
### 📖 Theory: Introduction to steps in jobs
6+
7+
[Steps](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idsteps) are the building blocks of jobs, allowing you to automate tasks like checking out code, running commands, or using open source Actions. They run sequentially in the job's environment but as independent processes. Unlike traditional code with a shared variable space, [inputs](https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#inputs) and [outputs](https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputs-for-docker-container-and-javascript-actions) must be explicitly declared.
8+
9+
> [!TIP]
10+
> The best part of GitHub Actions is the [marketplace](https://github.com/marketplace?type=actions) where the community has already built many free useful tools to [find and customize](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-pre-written-building-blocks-in-your-workflow)!
11+
12+
### ⌨️ Activity: Add a step to your workflow file
13+
14+
1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.
15+
16+
1. Add a step to the `welcome` job to post a comment on new pull requests using GitHub CLI:
17+
18+
```yaml
19+
name: Post welcome comment
20+
on:
21+
pull_request:
22+
types: [opened]
23+
permissions:
24+
pull-requests: write
25+
jobs:
26+
welcome:
27+
name: Post welcome comment
28+
runs-on: ubuntu-latest
29+
steps:
30+
- run: gh pr comment "$PR_URL" --body "Welcome to the repository!"
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
PR_URL: ${{ github.event.pull_request.html_url }}
34+
```
35+
36+
1. Commit your changes directly to `welcome-workflow` branch.
37+
38+
1. With the step information added, Mona will review your work and prepare the next step in this exercise!
39+
40+
<details>
41+
<summary>Having trouble? 🤷</summary><br/>
42+
43+
- Make sure the `steps` section is under the `welcome` job and properly indented.
44+
- Ensure you have the correct environment variables set.
45+
46+
</details>

.github/steps/4-merge-your-pull-request.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/steps/4-step.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Step 4: Trigger the workflow
2+
3+
_You've now added a fully functioning workflow to your repository! :smile:_
4+
5+
### 📖 Theory: Seeing your workflow in action
6+
7+
All the running and finished workflows can be seen on the **Actions** tab of your repository.
8+
9+
Because you set the workflow to run on the `pull_request` event, it will automatically trigger when a pull request is opened.
10+
11+
> [!TIP]
12+
> Workflow associated to pull request can also be seen on the pull request log near the merge button. You can even [create a rule](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#require-status-checks-to-pass-before-merging) that prevents merging if the workflow fails!
13+
14+
### ⌨️ Activity: Trigger the workflow
15+
16+
1. In the **Pull requests** tab, create a pull request from `welcome-workflow` branch into `main`.
17+
18+
1. Notice the comment that the workflow adds to the pull request.
19+
20+
1. Notice the area near the merge button that "All checks have passed".
21+
22+
1. With the pull request created and our workflow triggered, Mona will prepare the next step in this exercise!
23+
24+
### ⌨️ Activity: (optional) Inspect the workflow
25+
26+
1. At the top of the repository, select the **Actions** tab.
27+
28+
1. In the left sidebar, select the workflow named **Post welcome comment**.
29+
30+
> 💡 **Tip:** You can ignore the other actions. Those were for teaching this exercise.
31+
32+
1. Click the first run entry titled **Welcome workflow** to show a diagram of the run's jobs.
33+
34+
1. Click on the job named **Post welcome comment** to see the full logs.
35+
36+
37+
<details>
38+
<summary>Having trouble? 🤷</summary><br/>
39+
40+
- Check the **Actions** tab for workflow run details and errors.
41+
42+
</details>

0 commit comments

Comments
 (0)