Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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.

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

Welcome to "Hello GitHub Actions" exercise! :wave:

### 📖 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**—such as opening a pull request, pushing code, or creating an issue—that happen in your repository.

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#pull_request)

### ⌨️ 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
```

1. Commit your changes directly to the `welcome-workflow` branch.
1. As you commit your changes Mona will 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.

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

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

### 📖 Theory: Introduction to jobs

A **job** is a group of steps that run together on the same runner within a workflow. Jobs are defined in the workflow file under the `jobs` section. Each job runs independently by default, but you can configure jobs to depend on each other.

Jobs help you organize your workflow into logical units, such as building, testing, or deploying your code. Each job can run on different environments and can be configured to run in parallel or sequentially.

> [!NOTE]
>
> - [Jobs in GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs)

### ⌨️ 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 a job section as shown below:

```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 directly to the `welcome-workflow` branch.
1. As you commit your changes Mona will 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.

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

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

### 📖 Theory: Introduction to steps in jobs

A **step** is an individual task that is part of a job. Steps run in order, top-down, and can be shell scripts or actions. Each step runs in the same environment as the job, and the output of one step can be used by the next.

Steps are the building blocks of jobs, allowing you to automate tasks like checking out code, running commands, or using open source actions from the GitHub Marketplace.

> [!NOTE]
>
> - [Finding and customizing actions](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
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 }}
```

> ❗ **Caution:** The `steps` section must be indented under the `welcome` job. At the same level as `name` and `runs-on` parameters. Ensure that the indentation is correct to avoid syntax errors.

1. Commit your changes directly to `welcome-workflow` branch.
1. As you commit your changes Mona will 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.

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

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

### 📖 Theory: Seeing your workflow in action

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

> [!NOTE]
> The status of each workflow run that's triggered is shown in the pull request before it's merged. You can also see a list of all the workflows that are running, or have finished running, in the **Actions** tab of your repository.

### ⌨️ 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.


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

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

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

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

### 📖 Theory: When workflows run

When you created a workflow in a branch, it is only active in that branch until you merge it into the `main` branch. Merging your workflow into `main` makes it available for all future pull requests and changes to your repository.

Once merged, every new pull request you open will automatically trigger the workflow you created.

> [!TIP]
> Unlike the `pull_request` event trigger, some event triggers will only work if the workflow file exists in the `main` branch. For example, workflows that use `workflow_dispatch` (manual runs) or `schedule` (scheduled runs) will not work unless the workflow file is present in `main`.
>
> See [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows) for more details.

### ⌨️ 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.

21 changes: 0 additions & 21 deletions .github/steps/X-finish.md

This file was deleted.

18 changes: 18 additions & 0 deletions .github/steps/x-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Finish

_Congratulations friend, you've completed this exercise!_

<img src="https://octodex.github.com/images/jetpacktocat.png" alt="Mona the Octocat wearing a jetpack and smiling." width="300" align="right"/>

Here's a recap of all the tasks you've accomplished in your repository:

1. You've created your first GitHub Actions workflow file.
1. You learned where to make your workflow file.
1. You defined an event trigger, a job, and a step for your workflow.
1. You're ready to automate anything you can dream of.

### What's next?

- [Take another exercise](https://skills.github.com/)
- [Learn more about GitHub Actions](https://docs.github.com/actions/)
- [Awesome Actions](https://github.com/sdras/awesome-actions)
Loading
Loading