Skip to content

feat: Migrate exercise to issue based flow #270

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

Merged
merged 13 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/steps/-step.txt

This file was deleted.

1 change: 0 additions & 1 deletion .github/steps/0-welcome.md

This file was deleted.

41 changes: 0 additions & 41 deletions .github/steps/1-create-a-workflow.md

This file was deleted.

48 changes: 48 additions & 0 deletions .github/steps/1-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## Step 1: Create a workflow file

### 📖 Theory: Introduction to workflows

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.

Workflows let you automate tasks like building, testing, or deploying your code, and can respond to almost any activity in your project.

> [!NOTE]
> If you want to learn more check out these resources:
> - [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)
> - [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows)

### ⌨️ Activity: Create a workflow file

1. Open this repository in a new browser tab so you can work on the steps while you read the instructions in this tab.

1. In the **Code** tab of your repository, create a new branch named `welcome-workflow`.

<img width="400" alt="create branch screenshot" src="https://github.com/user-attachments/assets/8aa4a918-c877-4214-9efe-c9a99ca6421b" />

1. In the `welcome-workflow` branch, navigate to the `.github/workflows` directory.

1. Create a new file named `welcome.yml` in the `.github/workflows` directory with the following content:

```yaml
name: Post welcome comment
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
```

> [!NOTE]
> This is an incomplete workflow file. It is normal if you receive an error message. One step at a time! 😎

1. Commit your changes directly to the `welcome-workflow` branch.

1. With your workflow file committed, Mona will check your work and prepare the next step in this exercise!

<details>
<summary>Having trouble? 🤷</summary><br/>

- Make sure you are on the `welcome-workflow` branch when creating the workflow file.
- Double-check the file path and YAML indentation.

</details>
38 changes: 0 additions & 38 deletions .github/steps/2-add-a-job.md

This file was deleted.

43 changes: 43 additions & 0 deletions .github/steps/2-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Step 2: Add a job to your workflow file

Nice work! :tada: You added a workflow file!

### 📖 Theory: Introduction to jobs

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.

Jobs help you organize your workflow into logical units, such as building, testing, or deploying your code.

> [!Tip]
> 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).

### ⌨️ Activity: Add a job to your workflow file

1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.

1. Edit the file to add the `jobs` section and 1 job named `welcome`, which will run on the latest Ubuntu operating system.

```yaml
name: Post welcome comment
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
jobs:
welcome:
name: Post welcome comment
runs-on: ubuntu-latest
```

1. Commit your changes to the `welcome-workflow` branch.

1. With the job information added, Mona will review your work and prepare the next step in this exercise!

<details>
<summary>Having trouble? 🤷</summary><br/>

- Make sure the `jobs` section is properly indented in your YAML file.
- Confirm you are editing the correct file and branch.

</details>
40 changes: 0 additions & 40 deletions .github/steps/3-add-actions.md

This file was deleted.

46 changes: 46 additions & 0 deletions .github/steps/3-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Step 3: Add a step to your workflow file

_Nice work adding a job to your workflow! :dancer:_

### 📖 Theory: Introduction to steps in jobs

[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.

> [!TIP]
> 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)!

### ⌨️ Activity: Add a step to your workflow file

1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.

1. Add a step to the `welcome` job to post a comment on new pull requests using GitHub CLI:

```yaml
name: Post welcome comment
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
jobs:
welcome:
name: Post welcome comment
runs-on: ubuntu-latest
steps:
- run: gh pr comment "$PR_URL" --body "Welcome to the repository!"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
```

1. Commit your changes directly to `welcome-workflow` branch.

1. With the step information added, Mona will review your work and prepare the next step in this exercise!

<details>
<summary>Having trouble? 🤷</summary><br/>

- Make sure the `steps` section is under the `welcome` job and properly indented.
- Ensure you have the correct environment variables set.

</details>
13 changes: 0 additions & 13 deletions .github/steps/4-merge-your-pull-request.md

This file was deleted.

42 changes: 42 additions & 0 deletions .github/steps/4-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Step 4: Trigger the workflow

_You've now added a fully functioning workflow to your repository! :smile:_

### 📖 Theory: Seeing your workflow in action

All the running and finished workflows can be seen on the **Actions** tab of your repository.

Because you set the workflow to run on the `pull_request` event, it will automatically trigger when a pull request is opened.

> [!TIP]
> 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!

### ⌨️ Activity: Trigger the workflow

1. In the **Pull requests** tab, create a pull request from `welcome-workflow` branch into `main`.

1. Notice the comment that the workflow adds to the pull request.

1. Notice the area near the merge button that "All checks have passed".

1. With the pull request created and our workflow triggered, Mona will prepare the next step in this exercise!

### ⌨️ Activity: (optional) Inspect the workflow

1. At the top of the repository, select the **Actions** tab.

1. In the left sidebar, select the workflow named **Post welcome comment**.

> 💡 **Tip:** You can ignore the other actions. Those were for teaching this exercise.

1. Click the first run entry titled **Welcome workflow** to show a diagram of the run's jobs.

1. Click on the job named **Post welcome comment** to see the full logs.


<details>
<summary>Having trouble? 🤷</summary><br/>

- Check the **Actions** tab for workflow run details and errors.

</details>
19 changes: 19 additions & 0 deletions .github/steps/5-step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Step 5: Merge and experiment

_Great job! You have created and tested your first GitHub Actions workflow!_ :rocket:

### 📖 Theory: When workflows run

When you create a workflow in a branch, it is only enabled for that branch until you merge it into the default branch (`main`). When a workflow is in the default branch it applies to the entire repository.

Every new pull request regardless of branch will now automatically trigger the workflow you created.

> [!TIP]
> Some event triggers, like [workflow_dispatch](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch) and [schedule](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule) will only work if the workflow file exists in default branch.

### ⌨️ Activity: Merging your pull request

1. Merge your pull request into the `main` branch.

1. (Optional) Try opening another pull request to see your workflow run again!

18 changes: 0 additions & 18 deletions .github/steps/5-trigger.md

This file was deleted.

Loading
Loading