From 7e444ab68766c14d3bd12c1547550180c2485b50 Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Tue, 27 May 2025 08:27:01 +0000 Subject: [PATCH 01/13] Update README --- README.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f1212103..50bedc7e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ -
- # Hello GitHub Actions _Create and run a GitHub Actions workflow._ -
- ## Welcome Automation is key for streamlining your work processes, and [GitHub Actions](https://docs.github.com/actions) is the best way to supercharge your workflow. @@ -24,23 +20,29 @@ In this course, you will: 4. Merge your pull request 5. See effect of the workflow -### How to start this course +### How to start this exercise -[![start-course](https://user-images.githubusercontent.com/1221423/235727646-4a590299-ffe5-480d-8cd5-8194ea184546.svg)](https://github.com/new?template_owner=skills&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=My+clone+repository&visibility=public) +Simply copy the exercise to your account, then give your favorite Octocat (Mona) **about 20 seconds** to prepare the first lesson, then **refresh the page**. -1. Right-click **Start course** and open the link in a new tab. -2. In the new tab, most of the prompts will automatically fill in for you. - - For owner, choose your personal account or an organization to host the repository. - - We recommend creating a public repository, as private repositories will [use Actions minutes](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions). - - Scroll down and click the **Create repository** button at the bottom of the form. -3. After your new repository is created, wait about 20 seconds, then refresh the page. Follow the step-by-step instructions in the new repository's README. +[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=FidelusAleksander&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=Exercise:Create+and+run+a+GitHub+Actions+Workflow&visibility=public) - +© 2025 GitHub • [Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) • [MIT License](https://gh.io/mit) From 297eda464ddf7397c1225e6bbab143f3dd58097c Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Tue, 27 May 2025 12:40:20 +0000 Subject: [PATCH 02/13] Migrate the exercise to issue based flow --- .github/steps/-step.txt | 1 - .github/steps/0-welcome.md | 1 - .github/steps/1-create-a-workflow.md | 41 --------- .github/steps/1-step.md | 40 ++++++++ .github/steps/2-add-a-job.md | 38 -------- .github/steps/2-step.md | 39 ++++++++ .github/steps/3-add-actions.md | 40 -------- .github/steps/3-step.md | 34 +++++++ .github/steps/4-merge-your-pull-request.md | 13 --- .github/steps/4-step.md | 24 +++++ .github/steps/5-trigger.md | 18 ---- .github/steps/X-finish.md | 24 ++--- .github/workflows/0-start-exercise.yml | 64 +++++++++++++ .github/workflows/0-welcome.yml | 91 ------------------- .github/workflows/1-create-a-workflow.yml | 71 --------------- .github/workflows/1-step.yml | 53 +++++++++++ .github/workflows/2-add-a-job.yml | 71 --------------- .github/workflows/2-step.yml | 53 +++++++++++ .github/workflows/3-add-actions.yml | 71 --------------- .github/workflows/3-step.yml | 53 +++++++++++ .../workflows/4-merge-your-pull-request.yml | 64 ------------- .github/workflows/4-step.yml | 54 +++++++++++ .github/workflows/5-trigger.yml | 66 -------------- 23 files changed, 426 insertions(+), 598 deletions(-) delete mode 100644 .github/steps/-step.txt delete mode 100644 .github/steps/0-welcome.md delete mode 100644 .github/steps/1-create-a-workflow.md create mode 100644 .github/steps/1-step.md delete mode 100644 .github/steps/2-add-a-job.md create mode 100644 .github/steps/2-step.md delete mode 100644 .github/steps/3-add-actions.md create mode 100644 .github/steps/3-step.md delete mode 100644 .github/steps/4-merge-your-pull-request.md create mode 100644 .github/steps/4-step.md delete mode 100644 .github/steps/5-trigger.md create mode 100644 .github/workflows/0-start-exercise.yml delete mode 100644 .github/workflows/0-welcome.yml delete mode 100644 .github/workflows/1-create-a-workflow.yml create mode 100644 .github/workflows/1-step.yml delete mode 100644 .github/workflows/2-add-a-job.yml create mode 100644 .github/workflows/2-step.yml delete mode 100644 .github/workflows/3-add-actions.yml create mode 100644 .github/workflows/3-step.yml delete mode 100644 .github/workflows/4-merge-your-pull-request.yml create mode 100644 .github/workflows/4-step.yml delete mode 100644 .github/workflows/5-trigger.yml diff --git a/.github/steps/-step.txt b/.github/steps/-step.txt deleted file mode 100644 index 573541ac..00000000 --- a/.github/steps/-step.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/.github/steps/0-welcome.md b/.github/steps/0-welcome.md deleted file mode 100644 index 1b85348d..00000000 --- a/.github/steps/0-welcome.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.github/steps/1-create-a-workflow.md b/.github/steps/1-create-a-workflow.md deleted file mode 100644 index 60448773..00000000 --- a/.github/steps/1-create-a-workflow.md +++ /dev/null @@ -1,41 +0,0 @@ -## Step 1: Create a workflow file - -_Welcome to "Hello GitHub Actions"! :wave:_ - -**What is _GitHub Actions_?**: GitHub Actions is a flexible way to automate nearly every aspect of your team's software workflow. You can automate testing, continuously deploy, review code, manage issues and pull requests, and much more. The best part, these workflows are stored as code in your repository and easily shared and reused across teams. To learn more, check out these resources: - -- The GitHub Actions feature page, see [GitHub Actions](https://github.com/features/actions). -- The "GitHub Actions" user documentation, see [GitHub Actions](https://docs.github.com/actions). - -**What is a _workflow_?**: A workflow is a configurable automated process that will run one or more jobs. Workflows are defined in special files in the `.github/workflows` directory and they execute based on your chosen event. For this exercise, we'll use a `pull_request` event. - -- To read more about workflows, jobs, and events, see "[Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)". -- If you want to learn more about the `pull_request` event before using it, see "[pull_request](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request)". - -To get you started, we ran an Actions workflow in your new repository that, among other things, created a branch for you to work in, called `welcome-workflow`. - -### :keyboard: Activity: Create a workflow file - -1. Open a new browser tab, and navigate to this same repository. Then, work on the steps in your second tab while you read the instructions in this tab. -1. Create a pull request. This will contain all of the changes you'll make throughout this part of the course. - - Click the **Pull Requests** tab, click **New pull request**, set `base: main` and `compare:welcome-workflow`, click **Create pull request**, then click **Create pull request** again. - -1. Navigate to the **Code** tab. -1. From the **main** branch dropdown, click on the **welcome-workflow** branch. -1. Navigate to the `.github/workflows/` folder, then select **Add file** and click on **Create new file**. -1. In the **Name your file** field, enter `welcome.yml`. -1. Add the following content to the `welcome.yml` file: - - ```yaml copy - name: Post welcome comment - on: - pull_request: - types: [opened] - permissions: - pull-requests: write - ``` - -1. To commit your changes, click **Commit changes**. -1. Type a commit message, select **Commit directly to the welcome-workflow branch** and click **Commit changes**. -1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). A separate Actions workflow in the repository (not the workflow you created) will run and will automatically replace the contents of this README file with instructions for the next step. diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md new file mode 100644 index 00000000..7dd40d91 --- /dev/null +++ b/.github/steps/1-step.md @@ -0,0 +1,40 @@ +## Step 1: Create a workflow file + +Welcome to "Hello GitHub Actions" exercise! :wave: + +### 📖 Theory: What is GitHub Actions and a workflow? + +> [!NOTE] +> GitHub Actions is a flexible way to automate nearly every aspect of your team's software workflow. Workflows are defined in special files in the `.github/workflows` directory and execute based on your chosen event. + +- [GitHub Actions feature page](https://github.com/features/actions) +- [GitHub Actions documentation](https://docs.github.com/actions) +- [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) +- [pull_request event](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request) + +### ⌨️ Activity: Create a workflow file and open a pull request + +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. Create a new branch named `welcome-workflow`. +1. In the `welcome-workflow` branch, create a new file at `.github/workflows/welcome.yml` 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. Create a pull request from the `welcome-workflow` branch to `main`. +1. Wait about 20 seconds, then refresh this page. + +
+Having trouble? 🤷
+ +- Make sure you are on the `welcome-workflow` branch when creating the workflow file. +- Double-check the file path and YAML indentation. + +
diff --git a/.github/steps/2-add-a-job.md b/.github/steps/2-add-a-job.md deleted file mode 100644 index da1c71f5..00000000 --- a/.github/steps/2-add-a-job.md +++ /dev/null @@ -1,38 +0,0 @@ -## Step 2: Add a job to your workflow file - -_Nice work! :tada: You added a workflow file!_ - -Here's what the entries in the `welcome.yml` file, on the `welcome-workflow` branch, mean: - -- `name: Post welcome comment` gives your workflow a name. This name will appear in the Actions tab of your repository. -- `on: pull_request: types: [opened]` indicates that your workflow will execute whenever someone opens a pull request in your repository. -- `permissions` assigns the workflow permissions to operate on the repository -- `pull-requests: write` gives the workflow permission to write to pull requests. This is needed to create the welcome comment. - -Next, we need to specify jobs to run. - -**What is a _job_?**: A job is a set of steps in a workflow that execute on the same runner (a runner is a server that runs your workflows when triggered). Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. You'll add steps to your workflow later in the course. To read more about jobs, see "[Jobs](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs)". - -In the following activity, you'll add a "build" job to your workflow. You'll specify `ubuntu-latest` as the fastest, and cheapest, job runner available. If you want to read more about why we'll use that runner, see the code explanation for the line `runs-on: ubuntu-latest` in the "[Understanding the workflow file](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#understanding-the-workflow-file)" article. - -### :keyboard: Activity: Add a job to your workflow file - -1. In a separate browser tab, make sure you are on the `welcome-workflow` branch and open your `.github/workflows/welcome.yml` file. -1. Edit the file and update its contents to: - - ```yaml copy - name: Post welcome comment - on: - pull_request: - types: [opened] - permissions: - pull-requests: write - jobs: - build: - name: Post welcome comment - runs-on: ubuntu-latest - ``` - -1. Click **Commit changes** in the top right of the workflow editor. -1. Type a commit message and commit your changes directly to the `welcome-workflow` branch. -1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace the contents of this README file with instructions for the next step. diff --git a/.github/steps/2-step.md b/.github/steps/2-step.md new file mode 100644 index 00000000..df27f225 --- /dev/null +++ b/.github/steps/2-step.md @@ -0,0 +1,39 @@ +## Step 2: Add a job to your workflow file + +Nice work! :tada: You added a workflow file! + +### 📖 Theory: What is a job in GitHub Actions? + +> [!NOTE] +> A job is a set of steps in a workflow that execute on the same runner. Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. + +- [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: + build: + name: Post welcome comment + runs-on: ubuntu-latest + ``` + +1. Commit your changes directly to the `welcome-workflow` branch. +1. Wait about 20 seconds, then refresh this page. + +
+Having trouble? 🤷
+ +- Make sure the `jobs` section is properly indented in your YAML file. +- Confirm you are editing the correct file and branch. + +
diff --git a/.github/steps/3-add-actions.md b/.github/steps/3-add-actions.md deleted file mode 100644 index 8e38197a..00000000 --- a/.github/steps/3-add-actions.md +++ /dev/null @@ -1,40 +0,0 @@ -## Step 3: Add a step to your workflow file - -_Nice work adding a job to your workflow! :dancer:_ - -Workflows have jobs, and jobs have steps. So now we'll add a step to your workflow. - -**What are _steps_?**: Actions steps run - in the order they are specified, from the top down - when a workflow job is processed. Each step must pass for the next step to run. - -Each step consists of either a shell script that's executed, or a reference to an action that's run. When we talk about an action (with a lowercase "a") in this context, we mean a reusable unit of code. You can find out about actions in "[Finding and customizing actions](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions)," but for now we'll use a shell script in our workflow step. - -Update your workflow to make it post a comment on new pull requests. It will do this using a [bash](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) script and [GitHub CLI](https://cli.github.com/). - -### :keyboard: Activity: Add a step to your workflow file - -1. Still working on the `welcome-workflow` branch, open your `welcome.yml` file. -1. Update the contents of the file to: - - ```yaml copy - name: Post welcome comment - on: - pull_request: - types: [opened] - permissions: - pull-requests: write - jobs: - build: - 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 }} - ``` - - **Note:** The step you've added uses GitHub CLI (`gh`) to add a comment when a pull request is opened. To allow GitHub CLI to post a comment, we set the `GITHUB_TOKEN` environment variable to the value of the `GITHUB_TOKEN` secret, which is an installation access token, created when the workflow runs. For more information, see "[Automatic token authentication](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)." We set the `PR_URL` environment variable to the URL of the newly created pull request, and we use this in the `gh` command. - -1. Click **Commit changes** in the top right of the workflow editor. -1. Type your commit message and commit your changes directly to your branch. -1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace the contents of this README file with instructions for the next step. diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md new file mode 100644 index 00000000..b3d7ed6d --- /dev/null +++ b/.github/steps/3-step.md @@ -0,0 +1,34 @@ +## Step 3: Add a step to your workflow file + +_Nice work adding a job to your workflow! :dancer:_ + +### 📖 Theory: What are steps in a workflow? + +> [!NOTE] +> Steps run in order, top-down, when a workflow job is processed. Each step must pass for the next to run. Each step is either a shell script or a reference to an action. + +- [Finding and customizing actions](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions) + +### ⌨️ 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 `build` 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 }} + ``` + +1. Commit your changes directly to your branch. +1. Wait about 20 seconds, then refresh this page. + +
+Having trouble? 🤷
+ +- Make sure the `steps` section is under the `build` job and properly indented. +- Ensure you have the correct environment variables set. + +
diff --git a/.github/steps/4-merge-your-pull-request.md b/.github/steps/4-merge-your-pull-request.md deleted file mode 100644 index f30a0457..00000000 --- a/.github/steps/4-merge-your-pull-request.md +++ /dev/null @@ -1,13 +0,0 @@ -## Step 4: Merge your workflow file - -_You're now able to write and run an Actions workflow! :sparkles:_ - -Merge your changes so the action will be a part of the `main` branch. - -### :keyboard: Activity: Merge your workflow file - -1. In your repo, click on the **Pull requests** tab. -1. Click on the pull request you created in step 1. -1. Click **Merge pull request**, then click **Confirm merge**. -1. Optionally, click **Delete branch** to delete your `welcome-workflow` branch. -1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace the contents of this README file with instructions for the next step. diff --git a/.github/steps/4-step.md b/.github/steps/4-step.md new file mode 100644 index 00000000..8b9afd21 --- /dev/null +++ b/.github/steps/4-step.md @@ -0,0 +1,24 @@ +## Step 4: Trigger the workflow + +_You've now added a fully functioning workflow to your repository! :smile:_ + +The shell script in the workflow will run whenever a new pull request is opened. + +### 📖 Theory: Seeing your action in action + +> [!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 that will merge `welcome-workflow` into `main`. +1. Watch the workflow running in the checks section of the pull request. +1. Notice the comment that the workflow adds to the pull request. + +
+Having trouble? 🤷
+ +- Make sure your workflow file is in the correct location and named properly. +- Check the **Actions** tab for workflow run details and errors. + +
diff --git a/.github/steps/5-trigger.md b/.github/steps/5-trigger.md deleted file mode 100644 index 503bd034..00000000 --- a/.github/steps/5-trigger.md +++ /dev/null @@ -1,18 +0,0 @@ -## Step 5: Trigger the workflow - -_You've now added a fully functioning workflow to your repository! :smile:_ - -The shell script in the workflow will run whenever a new pull request is opened. - -**Seeing your _action_ in action**: The status of each workflow run that's triggered is shown in the pull request before it's merged: look for **All checks have passed** when you try out the steps below. You can also see a list of all the workflows that are running, or have finished running, in the **Actions** tab of your repository. From there, you can click on each workflow run to view more details and access log files. - -![A screenshot of the Actions tab showing a list of workflow runs.](https://user-images.githubusercontent.com/16547949/62388049-4e64e600-b52a-11e9-8bf5-db0c5452360f.png) - -### :keyboard: Activity: Trigger the workflow - -1. Make a new branch named `test-workflow`. -1. Make a change, such as adding an emoji to your README.md file, and commit the change directly to your new branch. -1. In the **Pull requests** tab, create a pull request that will merge `test-workflow` into `main`. -1. Watch the workflow running in the checks section of the pull request. -1. Notice the comment that the workflow adds to the pull request. -1. Wait about 20 seconds, then refresh this page (the one you're following instructions from). Another workflow will run and will replace the contents of this README file with instructions for the next step. diff --git a/.github/steps/X-finish.md b/.github/steps/X-finish.md index 278033e5..02fdbf21 100644 --- a/.github/steps/X-finish.md +++ b/.github/steps/X-finish.md @@ -1,21 +1,21 @@ ## Finish -_Congratulations friend, you've completed this course!_ +_Congratulations friend, you've completed this exercise!_ -Mona the Octocat wearing a jetpack and smiling. +Mona the Octocat wearing a jetpack and smiling. Here's a recap of all the tasks you've accomplished in your repository: -- You've created your first GitHub Actions workflow file. -- You learned where to make your workflow file. -- You defined an event trigger, a job, and a step for your workflow. -- You're ready to automate anything you can dream of. +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? -- Learn more about GitHub Actions by reading "[Learn GitHub Actions](https://docs.github.com/actions/learn-github-actions)" -- Use actions created by others in [awesome-actions](https://github.com/sdras/awesome-actions) -- We'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions) -- [Take another course on GitHub Actions](https://skills.github.com/#automate-workflows-with-github-actions) -- Learn more about GitHub by reading the "[Get started](https://docs.github.com/get-started)" docs -- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore) +- [Learn more about GitHub Actions](https://docs.github.com/actions/learn-github-actions) +- [Awesome Actions](https://github.com/sdras/awesome-actions) +- [Discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions) +- [Take another course](https://skills.github.com/#automate-workflows-with-github-actions) +- [Get started with GitHub](https://docs.github.com/get-started) +- [GitHub Explore](https://github.com/explore) diff --git a/.github/workflows/0-start-exercise.yml b/.github/workflows/0-start-exercise.yml new file mode 100644 index 00000000..aa4c5cb4 --- /dev/null +++ b/.github/workflows/0-start-exercise.yml @@ -0,0 +1,64 @@ +name: Step 0 # Start Exercise + +on: + push: + branches: + - main + +permissions: + contents: write + actions: write + issues: write + +env: + STEP_1_FILE: ".github/steps/1-step.md" + +jobs: + start_exercise: + name: Start Exercise + uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.4.0 + with: + exercise-title: "Hello GitHub Actions" + intro-message: "Create and run a GitHub Actions workflow." + + post_next_step_content: + name: Post next step content + runs-on: ubuntu-latest + needs: [start_exercise] + env: + ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + - name: Build comment - add step content + id: build-comment + uses: skills/action-text-variables@v2 + with: + template-file: ${{ env.STEP_1_FILE }} + template-vars: | + login: ${{ github.actor }} + full_repo_name: ${{ github.repository }} + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-comment.outputs.updated-text }} + - name: Create comment - watching for progress + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Enable next step workflow + run: | + gh workflow disable "${{github.workflow}}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/0-welcome.yml b/.github/workflows/0-welcome.yml deleted file mode 100644 index 90513dfe..00000000 --- a/.github/workflows/0-welcome.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Step 0, Welcome - -# This step triggers after the learner creates a new repository from the template. -# This workflow updates from step 0 to step 1. - -# This will run every time we create push a commit to `main`. -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - push: - branches: - - main - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_start: - name: On start - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 0. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 0 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # Make a branch, file, and commit for the learner. - - name: Prepare a branch, and file - run: | - echo "Make sure we are on step 0" - if [ "$(cat .github/steps/-step.txt)" != 0 ] - then - echo "Current step is not 0" - exit 0 - fi - - echo "Make a branch" - BRANCH=welcome-workflow - git checkout -b $BRANCH - - echo "Make a commit" - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git commit --allow-empty --message="Create an empty commit" - - echo "Push" - git push --set-upstream origin $BRANCH - - echo "Restore main" - git checkout main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # In README.md, switch step 0 for step 1. - - name: Update to step 1 - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 0 - to_step: 1 - branch_name: welcome-workflow diff --git a/.github/workflows/1-create-a-workflow.yml b/.github/workflows/1-create-a-workflow.yml deleted file mode 100644 index e3ef2b59..00000000 --- a/.github/workflows/1-create-a-workflow.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Step 1, Create a workflow - -# This step triggers after every push to welcome-workflow. -# This workflow updates from step 1 to step 2. - -# This will run every time we push to welcome-workflow. -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - push: - branches: - - welcome-workflow - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_create_workflow: - name: On create workflow - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 1. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 1 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # Verify the learner added the file contents. - - name: Check workflow contents, name - uses: skills/action-check-file@v1 - with: - file: ".github/workflows/welcome.yml" - search: "name:" - - # In README.md, switch step 1 for step 2. - - name: Update to step 2 - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 1 - to_step: 2 - branch_name: welcome-workflow diff --git a/.github/workflows/1-step.yml b/.github/workflows/1-step.yml new file mode 100644 index 00000000..46d4a8ed --- /dev/null +++ b/.github/workflows/1-step.yml @@ -0,0 +1,53 @@ +name: Step 1 + +on: + push: + branches: + - welcome-workflow + +permissions: + contents: read + actions: write + issues: write + +env: + STEP_2_FILE: ".github/steps/2-step.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + + post_next_step_content: + name: Post next step content + needs: [find_exercise] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$STEP_2_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create comment - watching for progress + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Disable current workflow and enable next one + run: | + gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 2" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/2-add-a-job.yml b/.github/workflows/2-add-a-job.yml deleted file mode 100644 index d48926c4..00000000 --- a/.github/workflows/2-add-a-job.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Step 2, Add a job - -# This step triggers after every push to welcome-workflow. -# This workflow updates from step 2 to step 3. - -# This will run every time we push to welcome-workflow. -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - push: - branches: - - welcome-workflow - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_add_job: - name: On add job - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 2. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 2 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # Verify the learner added the file contents. - - name: Check workflow contents, jobs - uses: skills/action-check-file@v1 - with: - file: ".github/workflows/welcome.yml" - search: "jobs:" - - # In README.md, switch step 2 for step 3. - - name: Update to step 3 - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 2 - to_step: 3 - branch_name: welcome-workflow diff --git a/.github/workflows/2-step.yml b/.github/workflows/2-step.yml new file mode 100644 index 00000000..cc11bbe5 --- /dev/null +++ b/.github/workflows/2-step.yml @@ -0,0 +1,53 @@ +name: Step 2 + +on: + push: + branches: + - welcome-workflow + +permissions: + contents: write + actions: write + issues: write + +env: + STEP_3_FILE: ".github/steps/3-step.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + + post_next_step_content: + name: Post next step content + needs: [find_exercise] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$STEP_3_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create comment - watching for progress + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Disable current workflow and enable next one + run: | + gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 3" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/3-add-actions.yml b/.github/workflows/3-add-actions.yml deleted file mode 100644 index 424be386..00000000 --- a/.github/workflows/3-add-actions.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Step 3, Add actions - -# This step triggers after every push to welcome-workflow. -# This workflow updates from step 3 to step 4. - -# This will run every time we push to welcome-workflow. -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - push: - branches: - - welcome-workflow - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_add_actions: - name: On add actions - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 3. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 3 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # Verify the learner added the file contents. - - name: Check workflow contents, steps - uses: skills/action-check-file@v1 - with: - file: ".github/workflows/welcome.yml" - search: "steps:" - - # In README.md, switch step 3 for step 4. - - name: Update to step 4 - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 3 - to_step: 4 - branch_name: welcome-workflow diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml new file mode 100644 index 00000000..56857483 --- /dev/null +++ b/.github/workflows/3-step.yml @@ -0,0 +1,53 @@ +name: Step 3 + +on: + push: + branches: + - welcome-workflow + +permissions: + contents: read + actions: write + issues: write + +env: + STEP_4_FILE: ".github/steps/4-step.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + + post_next_step_content: + name: Post next step content + needs: [find_exercise] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$STEP_4_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create comment - watching for progress + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Disable current workflow and enable next one + run: | + gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 4" + 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 deleted file mode 100644 index 44378bd6..00000000 --- a/.github/workflows/4-merge-your-pull-request.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Step 4, Merge your pull request - -# This step triggers after a pull request is merged to `main`. -# This workflow updates from step 4 to step 5. - -# This will run every time we create push a commit to `main`. -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - push: - branches: - - main - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_merge: - name: On merge - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 4. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 4 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # In README.md, switch step 4 for step 5. - - name: Update to step 5 - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 4 - to_step: 5 - branch_name: welcome-workflow diff --git a/.github/workflows/4-step.yml b/.github/workflows/4-step.yml new file mode 100644 index 00000000..2d377e7c --- /dev/null +++ b/.github/workflows/4-step.yml @@ -0,0 +1,54 @@ +name: Step 4 + +on: + pull_request: + branches: + - main + types: + - opened + +permissions: + contents: write + actions: write + issues: write + +env: + REVIEW_FILE: ".github/steps/X-finish.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + + post_review_content: + name: Post review content + needs: [find_exercise] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$REVIEW_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + finish_exercise: + name: Finish Exercise + needs: [find_exercise, post_review_content] + uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.4.0 + with: + issue-url: ${{ needs.find_exercise.outputs.issue-url }} + disable_workflow: + name: Disable this workflow + needs: [find_exercise, post_review_content] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Disable current workflow + run: gh workflow disable "${{github.workflow}}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/5-trigger.yml b/.github/workflows/5-trigger.yml deleted file mode 100644 index d12edc7a..00000000 --- a/.github/workflows/5-trigger.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Step 5, Trigger the workflow - -# This step triggers after we finish running "Post welcome comment". -# This workflow updates from step 5 to step X. - -# This will run every time we finish running "Post welcome comment". -# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows -on: - workflow_dispatch: - workflow_run: - workflows: - - Post welcome comment - types: - - completed - -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication -permissions: - # Need `contents: read` to checkout the repository. - # Need `contents: write` to update the step metadata. - contents: write - -jobs: - # Get the current step to only run the main job when the learner is on the same step. - get_current_step: - name: Check current step number - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: get_step - run: | - echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT - outputs: - current_step: ${{ steps.get_step.outputs.current_step }} - - on_trigger: - name: On trigger - needs: get_current_step - - # We will only run this action when: - # 1. This repository isn't the template repository. - # 2. The step is currently 5. - # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts - # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions - if: >- - ${{ !github.event.repository.is_template - && needs.get_current_step.outputs.current_step == 5 }} - - # We'll run Ubuntu for performance instead of Mac or Windows. - runs-on: ubuntu-latest - - steps: - # We'll need to check out the repository so that we can edit the README. - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Let's get all the branches. - - # In README.md, switch step 5 for step X. - - name: Update to step X - uses: skills/action-update-step@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - from_step: 5 - to_step: X - branch_name: test-workflow From 55459bddc6a56f03c3fb2ed1badedecde4525051 Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 08:24:57 +0000 Subject: [PATCH 03/13] Minor wording tweaks --- .github/steps/1-step.md | 3 +-- .github/steps/2-step.md | 2 +- .github/steps/3-step.md | 2 +- .github/steps/4-step.md | 1 + .github/steps/{X-finish.md => x-review.md} | 4 ++-- .github/workflows/0-start-exercise.yml | 2 +- .github/workflows/4-step.yml | 2 +- README.md | 14 +++++++------- 8 files changed, 15 insertions(+), 15 deletions(-) rename .github/steps/{X-finish.md => x-review.md} (88%) diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index 7dd40d91..770349b9 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -28,8 +28,7 @@ Welcome to "Hello GitHub Actions" exercise! :wave: ``` 1. Commit your changes directly to the `welcome-workflow` branch. -1. Create a pull request from the `welcome-workflow` branch to `main`. -1. Wait about 20 seconds, then refresh this page. +1. As you commit your changes Mona will prepare the next step in this exercise!
Having trouble? 🤷
diff --git a/.github/steps/2-step.md b/.github/steps/2-step.md index df27f225..696014cc 100644 --- a/.github/steps/2-step.md +++ b/.github/steps/2-step.md @@ -28,7 +28,7 @@ Nice work! :tada: You added a workflow file! ``` 1. Commit your changes directly to the `welcome-workflow` branch. -1. Wait about 20 seconds, then refresh this page. +1. As you commit your changes Mona will prepare the next step in this exercise!
Having trouble? 🤷
diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index b3d7ed6d..1d1d01a2 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -23,7 +23,7 @@ _Nice work adding a job to your workflow! :dancer:_ ``` 1. Commit your changes directly to your branch. -1. Wait about 20 seconds, then refresh this page. +1. As you commit your changes Mona will prepare the next step in this exercise!
Having trouble? 🤷
diff --git a/.github/steps/4-step.md b/.github/steps/4-step.md index 8b9afd21..480a1548 100644 --- a/.github/steps/4-step.md +++ b/.github/steps/4-step.md @@ -15,6 +15,7 @@ The shell script in the workflow will run whenever a new pull request is opened. 1. Watch the workflow running in the checks section of the pull request. 1. Notice the comment that the workflow adds to the pull request. +
Having trouble? 🤷
diff --git a/.github/steps/X-finish.md b/.github/steps/x-review.md similarity index 88% rename from .github/steps/X-finish.md rename to .github/steps/x-review.md index 02fdbf21..4c6b45e6 100644 --- a/.github/steps/X-finish.md +++ b/.github/steps/x-review.md @@ -13,9 +13,9 @@ Here's a recap of all the tasks you've accomplished in your repository: ### What's next? -- [Learn more about GitHub Actions](https://docs.github.com/actions/learn-github-actions) +- [Learn more about GitHub Actions](https://docs.github.com/actions/) - [Awesome Actions](https://github.com/sdras/awesome-actions) - [Discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions) -- [Take another course](https://skills.github.com/#automate-workflows-with-github-actions) +- [Take another exercise](https://skills.github.com/#automate-workflows-with-github-actions) - [Get started with GitHub](https://docs.github.com/get-started) - [GitHub Explore](https://github.com/explore) diff --git a/.github/workflows/0-start-exercise.yml b/.github/workflows/0-start-exercise.yml index aa4c5cb4..f6a8974b 100644 --- a/.github/workflows/0-start-exercise.yml +++ b/.github/workflows/0-start-exercise.yml @@ -59,6 +59,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Enable next step workflow run: | - gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 1" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-step.yml b/.github/workflows/4-step.yml index 2d377e7c..c3b75a61 100644 --- a/.github/workflows/4-step.yml +++ b/.github/workflows/4-step.yml @@ -13,7 +13,7 @@ permissions: issues: write env: - REVIEW_FILE: ".github/steps/X-finish.md" + REVIEW_FILE: ".github/steps/x-review.md" jobs: find_exercise: diff --git a/README.md b/README.md index 50bedc7e..8e5cdec2 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,16 @@ Automation is key for streamlining your work processes, and [GitHub Actions](htt - **Who is this for**: Developers, DevOps engineers, students, managers, teams, GitHub users. - **What you'll learn**: How to create workflow files, trigger workflows, and find workflow logs. - **What you'll build**: An Actions workflow that will check emoji shortcode references in Markdown files. -- **Prerequisites**: In this course you will work with issues and pull requests, as well as edit files. We recommend you take the [Introduction to GitHub](https://github.com/skills/introduction-to-github) course first. -- **How long**: This course can be finished in less than two hours. +- **Prerequisites**: In this exercise you will work with issues and pull requests, as well as edit files. We recommend you take the [Introduction to GitHub](https://github.com/skills/introduction-to-github) exercise first. +- **How long**: This exercise can be finished in less than two hours. -In this course, you will: +In this exercise, you will: 1. Create a workflow -2. Add a job -3. Add a run step -4. Merge your pull request -5. See effect of the workflow +1. Add a job +1. Add a run step +1. Merge your pull request +1. See effect of the workflow ### How to start this exercise From eaa7896d841d7947962f4f9a3309aa82b05ffb0d Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 10:26:39 +0000 Subject: [PATCH 04/13] Add grading workflows and update theory --- .github/steps/1-step.md | 19 +++--- .github/steps/2-step.md | 13 ++-- .github/steps/3-step.md | 15 +++-- .github/steps/4-step.md | 1 - .github/steps/5-step.md | 20 ++++++ .github/workflows/1-step.yml | 116 ++++++++++++++++++++++++++++++++++- .github/workflows/2-step.yml | 97 ++++++++++++++++++++++++++++- .github/workflows/3-step.yml | 116 ++++++++++++++++++++++++++++++++++- .github/workflows/4-step.yml | 39 ++++++------ .github/workflows/5-step.yml | 54 ++++++++++++++++ 10 files changed, 448 insertions(+), 42 deletions(-) create mode 100644 .github/steps/5-step.md create mode 100644 .github/workflows/5-step.yml diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index 770349b9..e5833694 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -2,21 +2,24 @@ Welcome to "Hello GitHub Actions" exercise! :wave: -### 📖 Theory: What is GitHub Actions and a workflow? +### 📖 Theory: Introduction to workflows, workflow files, and event triggers -> [!NOTE] -> GitHub Actions is a flexible way to automate nearly every aspect of your team's software workflow. Workflows are defined in special files in the `.github/workflows` directory and execute based on your chosen event. +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. -- [GitHub Actions feature page](https://github.com/features/actions) -- [GitHub Actions documentation](https://docs.github.com/actions) -- [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) -- [pull_request event](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request) +> [!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 and open a pull request 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. Create a new branch named `welcome-workflow`. -1. In the `welcome-workflow` branch, create a new file at `.github/workflows/welcome.yml` with the following content: + +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 diff --git a/.github/steps/2-step.md b/.github/steps/2-step.md index 696014cc..d410ca5c 100644 --- a/.github/steps/2-step.md +++ b/.github/steps/2-step.md @@ -2,12 +2,15 @@ Nice work! :tada: You added a workflow file! -### 📖 Theory: What is a job in GitHub Actions? +### 📖 Theory: Introduction to jobs in GitHub Actions workflows -> [!NOTE] -> A job is a set of steps in a workflow that execute on the same runner. Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. +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. -- [Jobs in GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs) +> [!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 @@ -22,7 +25,7 @@ Nice work! :tada: You added a workflow file! permissions: pull-requests: write jobs: - build: + welcome: name: Post welcome comment runs-on: ubuntu-latest ``` diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index 1d1d01a2..1e739f64 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -2,12 +2,15 @@ _Nice work adding a job to your workflow! :dancer:_ -### 📖 Theory: What are steps in a workflow? +### 📖 Theory: Introduction to steps in jobs -> [!NOTE] -> Steps run in order, top-down, when a workflow job is processed. Each step must pass for the next to run. Each step is either a shell script or a reference to an action. +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. -- [Finding and customizing actions](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions) +> [!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 @@ -22,13 +25,13 @@ _Nice work adding a job to your workflow! :dancer:_ PR_URL: ${{ github.event.pull_request.html_url }} ``` -1. Commit your changes directly to your branch. +1. Commit your changes directly to `welcome-workflow` branch. 1. As you commit your changes Mona will prepare the next step in this exercise!
Having trouble? 🤷
-- Make sure the `steps` section is under the `build` job and properly indented. +- Make sure the `steps` section is under the `welcome` job and properly indented. - Ensure you have the correct environment variables set.
diff --git a/.github/steps/4-step.md b/.github/steps/4-step.md index 480a1548..73e7d2c2 100644 --- a/.github/steps/4-step.md +++ b/.github/steps/4-step.md @@ -19,7 +19,6 @@ The shell script in the workflow will run whenever a new pull request is opened.
Having trouble? 🤷
-- Make sure your workflow file is in the correct location and named properly. - Check the **Actions** tab for workflow run details and errors.
diff --git a/.github/steps/5-step.md b/.github/steps/5-step.md new file mode 100644 index 00000000..ff1e7872 --- /dev/null +++ b/.github/steps/5-step.md @@ -0,0 +1,20 @@ +## Step 5: Merge your workflow 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! + diff --git a/.github/workflows/1-step.yml b/.github/workflows/1-step.yml index 46d4a8ed..43dc02b2 100644 --- a/.github/workflows/1-step.yml +++ b/.github/workflows/1-step.yml @@ -18,9 +18,123 @@ jobs: name: Find Exercise Issue uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + + - name: Update comment - checking work + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if welcome.yml file exists + id: check-file-exists + continue-on-error: true + uses: skills/exercise-toolkit/actions/file-exists@v0.4.0 + with: + file: .github/workflows/welcome.yml + + - name: Check for workflow name in welcome.yml + id: check-workflow-name + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "name:" + + - name: Check for pull_request event in welcome.yml + id: check-pull-request-event + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "pull_request:" + + - name: Check for opened type in welcome.yml + id: check-opened-type + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "types: [opened]" + + - name: Check for permissions in welcome.yml + id: check-permissions + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "pull-requests: write" + + - name: Build message - step results + id: build-message-step-results + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md + template-vars: | + step_number: 1 + passed: ${{ !contains(steps.*.outcome, 'failure') }} + results_table: + - description: "Created welcome.yml file in .github/workflows directory" + passed: ${{ steps.check-file-exists.outcome == 'success' }} + - description: "Added a workflow name field" + passed: ${{ steps.check-workflow-name.outcome == 'success' }} + - description: "Configured pull_request event trigger" + passed: ${{ steps.check-pull-request-event.outcome == 'success' }} + - description: "Set types to [opened] for pull_request event" + passed: ${{ steps.check-opened-type.outcome == 'success' }} + - description: "Added pull-requests: write permission" + passed: ${{ steps.check-permissions.outcome == 'success' }} + + - name: Create comment - step results + run: | + gh issue comment "$ISSUE_URL" \ + --body "$COMMENT_BODY" \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }} + + - name: Fail job if not all checks passed + if: contains(steps.*.outcome, 'failure') + run: exit 1 + + - name: Build message - step finished + id: build-message-step-finish + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md + template-vars: | + next_step_number: 2 + + - name: Update comment - step finished + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }} + post_next_step_content: name: Post next step content - needs: [find_exercise] + needs: [find_exercise, check_step_work] runs-on: ubuntu-latest env: ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} diff --git a/.github/workflows/2-step.yml b/.github/workflows/2-step.yml index cc11bbe5..5b090b8c 100644 --- a/.github/workflows/2-step.yml +++ b/.github/workflows/2-step.yml @@ -18,9 +18,104 @@ jobs: name: Find Exercise Issue uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + + - name: Update comment - checking work + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check for jobs section in welcome.yml + id: check-jobs-section + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "jobs:" + + - name: Check for welcome job in welcome.yml + id: check-welcome-job + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "welcome:" + + - name: Check for runs-on ubuntu-latest in welcome.yml + id: check-runs-on + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "runs-on: ubuntu-latest" + + - name: Build message - step results + id: build-message-step-results + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md + template-vars: | + step_number: 2 + passed: ${{ !contains(steps.*.outcome, 'failure') }} + results_table: + - description: "Added jobs section to workflow file" + passed: ${{ steps.check-jobs-section.outcome == 'success' }} + - description: "Created welcome job" + passed: ${{ steps.check-welcome-job.outcome == 'success' }} + - description: "Set runs-on to ubuntu-latest" + passed: ${{ steps.check-runs-on.outcome == 'success' }} + + - name: Create comment - step results + run: | + gh issue comment "$ISSUE_URL" \ + --body "$COMMENT_BODY" \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }} + + - name: Fail job if not all checks passed + if: contains(steps.*.outcome, 'failure') + run: exit 1 + + - name: Build message - step finished + id: build-message-step-finish + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md + template-vars: | + next_step_number: 3 + + - name: Update comment - step finished + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }} + post_next_step_content: name: Post next step content - needs: [find_exercise] + needs: [find_exercise, check_step_work] runs-on: ubuntu-latest env: ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml index 56857483..40dc7e05 100644 --- a/.github/workflows/3-step.yml +++ b/.github/workflows/3-step.yml @@ -18,9 +18,123 @@ jobs: name: Find Exercise Issue uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 + + - name: Update comment - checking work + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Lint welcome.yml with actionlint + id: actionlint-check + continue-on-error: true + uses: raven-actions/actionlint@v1 + with: + files: .github/workflows/welcome.yml + + - name: Check for steps section in welcome.yml + id: check-steps-section + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "steps:" + + - name: Check for gh pr comment command in welcome.yml + id: check-gh-pr-comment + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "gh pr comment" + + - name: Check for GITHUB_TOKEN env var in welcome.yml + id: check-github-token + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "GITHUB_TOKEN:" + + - name: Check for PR_URL env var in welcome.yml + id: check-pr-url + continue-on-error: true + uses: skills/action-keyphrase-checker@v1 + with: + text-file: .github/workflows/welcome.yml + keyphrase: "PR_URL:" + + - name: Build message - step results + id: build-message-step-results + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md + template-vars: | + step_number: 3 + passed: ${{ !contains(steps.*.outcome, 'failure') }} + results_table: + - description: "Workflow file passes actionlint syntax validation" + passed: ${{ steps.actionlint-check.outcome == 'success' }} + - description: "Added steps section to welcome job" + passed: ${{ steps.check-steps-section.outcome == 'success' }} + - description: "Added gh pr comment command" + passed: ${{ steps.check-gh-pr-comment.outcome == 'success' }} + - description: "Set GITHUB_TOKEN environment variable" + passed: ${{ steps.check-github-token.outcome == 'success' }} + - description: "Set PR_URL environment variable" + passed: ${{ steps.check-pr-url.outcome == 'success' }} + + - name: Create comment - step results + run: | + gh issue comment "$ISSUE_URL" \ + --body "$COMMENT_BODY" \ + --edit-last + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }} + + - name: Fail job if not all checks passed + if: contains(steps.*.outcome, 'failure') + run: exit 1 + + - name: Build message - step finished + id: build-message-step-finish + uses: skills/action-text-variables@v2 + with: + template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md + template-vars: | + next_step_number: 4 + + - name: Update comment - step finished + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }} + post_next_step_content: name: Post next step content - needs: [find_exercise] + needs: [find_exercise, check_step_work] runs-on: ubuntu-latest env: ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} diff --git a/.github/workflows/4-step.yml b/.github/workflows/4-step.yml index c3b75a61..79fc3b16 100644 --- a/.github/workflows/4-step.yml +++ b/.github/workflows/4-step.yml @@ -13,15 +13,15 @@ permissions: issues: write env: - REVIEW_FILE: ".github/steps/x-review.md" + STEP_5_FILE: ".github/steps/5-step.md" jobs: find_exercise: name: Find Exercise Issue uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 - post_review_content: - name: Post review content + post_next_step_content: + name: Post next step content needs: [find_exercise] runs-on: ubuntu-latest env: @@ -29,26 +29,27 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.4.0 - name: Create comment - add step content run: | gh issue comment "$ISSUE_URL" \ - --body-file "$REVIEW_FILE" + --body-file "$STEP_5_FILE" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - finish_exercise: - name: Finish Exercise - needs: [find_exercise, post_review_content] - uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.4.0 - with: - issue-url: ${{ needs.find_exercise.outputs.issue-url }} - disable_workflow: - name: Disable this workflow - needs: [find_exercise, post_review_content] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Disable current workflow - run: gh workflow disable "${{github.workflow}}" + - name: Create comment - watching for progress + run: | + gh issue comment "$ISSUE_URL" \ + --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Disable current workflow and enable next one + run: | + gh workflow disable "${{github.workflow}}" + gh workflow enable "Step 5" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/5-step.yml b/.github/workflows/5-step.yml new file mode 100644 index 00000000..e7da2e8d --- /dev/null +++ b/.github/workflows/5-step.yml @@ -0,0 +1,54 @@ +name: Step 5 + +on: + pull_request: + branches: + - main + types: + - closed + +permissions: + contents: write + actions: write + issues: write + +env: + REVIEW_FILE: ".github/steps/x-review.md" + +jobs: + find_exercise: + name: Find Exercise Issue + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + + post_review_content: + name: Post review content + needs: [find_exercise] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$REVIEW_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + finish_exercise: + name: Finish Exercise + needs: [find_exercise, post_review_content] + uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.4.0 + with: + issue-url: ${{ needs.find_exercise.outputs.issue-url }} + disable_workflow: + name: Disable this workflow + needs: [find_exercise, post_review_content] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Disable current workflow + run: gh workflow disable "${{github.workflow}}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a7891d8fe560d887d8cc4fb7fd076e8d9e050422 Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 10:35:50 +0000 Subject: [PATCH 05/13] Updates to step 3 --- .github/steps/3-step.md | 2 +- .github/workflows/3-step.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index 1e739f64..4b0e6843 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -19,7 +19,7 @@ Steps are the building blocks of jobs, allowing you to automate tasks like check ```yaml steps: - - run: gh pr comment $PR_URL --body "Welcome to the repository!" + - 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 }} diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml index 40dc7e05..e468ad54 100644 --- a/.github/workflows/3-step.yml +++ b/.github/workflows/3-step.yml @@ -4,6 +4,8 @@ on: push: branches: - welcome-workflow + paths: + - ".github/workflows/welcome.yml" permissions: contents: read @@ -47,7 +49,7 @@ jobs: - name: Lint welcome.yml with actionlint id: actionlint-check continue-on-error: true - uses: raven-actions/actionlint@v1 + uses: raven-actions/actionlint@01fce4f43a270a612932cb1c64d40505a029f821 # v2.0.0 with: files: .github/workflows/welcome.yml @@ -58,6 +60,7 @@ jobs: with: text-file: .github/workflows/welcome.yml keyphrase: "steps:" + fail-on-error: true - name: Check for gh pr comment command in welcome.yml id: check-gh-pr-comment From 19709d8d4a3f9dab6fcfc4a0af8db73774eda1eb Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 10:59:08 +0000 Subject: [PATCH 06/13] Update exercise-toolkit references to v0.5.0 --- .github/workflows/0-start-exercise.yml | 4 ++-- .github/workflows/1-step.yml | 14 +++++++------- .github/workflows/2-step.yml | 6 +++--- .github/workflows/3-step.yml | 16 +++++++++++----- .github/workflows/4-step.yml | 4 ++-- .github/workflows/5-step.yml | 4 ++-- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/0-start-exercise.yml b/.github/workflows/0-start-exercise.yml index f6a8974b..f65abf0d 100644 --- a/.github/workflows/0-start-exercise.yml +++ b/.github/workflows/0-start-exercise.yml @@ -16,7 +16,7 @@ env: jobs: start_exercise: name: Start Exercise - uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.5.0 with: exercise-title: "Hello GitHub Actions" intro-message: "Create and run a GitHub Actions workflow." @@ -35,7 +35,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Build comment - add step content id: build-comment uses: skills/action-text-variables@v2 diff --git a/.github/workflows/1-step.yml b/.github/workflows/1-step.yml index 43dc02b2..a846342c 100644 --- a/.github/workflows/1-step.yml +++ b/.github/workflows/1-step.yml @@ -16,7 +16,7 @@ env: jobs: find_exercise: name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0 check_step_work: name: Check step work @@ -34,7 +34,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Update comment - checking work run: | @@ -47,7 +47,7 @@ jobs: - name: Check if welcome.yml file exists id: check-file-exists continue-on-error: true - uses: skills/exercise-toolkit/actions/file-exists@v0.4.0 + uses: skills/exercise-toolkit/actions/file-exists@v0.5.0 with: file: .github/workflows/welcome.yml @@ -67,13 +67,13 @@ jobs: text-file: .github/workflows/welcome.yml keyphrase: "pull_request:" - - name: Check for opened type in welcome.yml + - name: Check for types filter id: check-opened-type continue-on-error: true uses: skills/action-keyphrase-checker@v1 with: text-file: .github/workflows/welcome.yml - keyphrase: "types: [opened]" + keyphrase: "types:" - name: Check for permissions in welcome.yml id: check-permissions @@ -98,7 +98,7 @@ jobs: passed: ${{ steps.check-workflow-name.outcome == 'success' }} - description: "Configured pull_request event trigger" passed: ${{ steps.check-pull-request-event.outcome == 'success' }} - - description: "Set types to [opened] for pull_request event" + - description: "Set types filter for pull_request event" passed: ${{ steps.check-opened-type.outcome == 'success' }} - description: "Added pull-requests: write permission" passed: ${{ steps.check-permissions.outcome == 'success' }} @@ -146,7 +146,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Create comment - add step content run: | gh issue comment "$ISSUE_URL" \ diff --git a/.github/workflows/2-step.yml b/.github/workflows/2-step.yml index 5b090b8c..b201a06b 100644 --- a/.github/workflows/2-step.yml +++ b/.github/workflows/2-step.yml @@ -16,7 +16,7 @@ env: jobs: find_exercise: name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0 check_step_work: name: Check step work @@ -34,7 +34,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Update comment - checking work run: | @@ -127,7 +127,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Create comment - add step content run: | gh issue comment "$ISSUE_URL" \ diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml index e468ad54..e7a78dc1 100644 --- a/.github/workflows/3-step.yml +++ b/.github/workflows/3-step.yml @@ -2,8 +2,14 @@ name: Step 3 on: push: - branches: - - welcome-workflow + bra - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: v0.5.0 + + - name: Update comment - checking work - welcome-workflow paths: - ".github/workflows/welcome.yml" @@ -18,7 +24,7 @@ env: jobs: find_exercise: name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0 check_step_work: name: Check step work @@ -36,7 +42,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Update comment - checking work run: | @@ -149,7 +155,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Create comment - add step content run: | gh issue comment "$ISSUE_URL" \ diff --git a/.github/workflows/4-step.yml b/.github/workflows/4-step.yml index 79fc3b16..30f14002 100644 --- a/.github/workflows/4-step.yml +++ b/.github/workflows/4-step.yml @@ -18,7 +18,7 @@ env: jobs: find_exercise: name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0 post_next_step_content: name: Post next step content @@ -34,7 +34,7 @@ jobs: with: repository: skills/exercise-toolkit path: exercise-toolkit - ref: v0.4.0 + ref: v0.5.0 - name: Create comment - add step content run: | gh issue comment "$ISSUE_URL" \ diff --git a/.github/workflows/5-step.yml b/.github/workflows/5-step.yml index e7da2e8d..4a56ac08 100644 --- a/.github/workflows/5-step.yml +++ b/.github/workflows/5-step.yml @@ -18,7 +18,7 @@ env: jobs: find_exercise: name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0 post_review_content: name: Post review content @@ -38,7 +38,7 @@ jobs: finish_exercise: name: Finish Exercise needs: [find_exercise, post_review_content] - uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.4.0 + uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.5.0 with: issue-url: ${{ needs.find_exercise.outputs.issue-url }} disable_workflow: From d7da0f3ddce3d284e89524c0e464984d450e0e79 Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 11:15:14 +0000 Subject: [PATCH 07/13] Test run updates --- .github/steps/1-step.md | 2 +- .github/steps/3-step.md | 2 +- .github/workflows/1-step.yml | 2 ++ .github/workflows/3-step.yml | 10 ++-------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index e5833694..ee448e6d 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -16,7 +16,7 @@ Workflows let you automate tasks like building, testing, or deploying your code, ### ⌨️ Activity: Create a workflow file and open a pull request 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. Create a new branch named `welcome-workflow`. +1. In the **Code** tab of your repository, create a new branch named `welcome-workflow`. 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: diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index 4b0e6843..96d7ebe1 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -15,7 +15,7 @@ Steps are the building blocks of jobs, allowing you to automate tasks like check ### ⌨️ 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 `build` job to post a comment on new pull requests using GitHub CLI: +1. Add a step to the `welcome` job to post a comment on new pull requests using GitHub CLI: ```yaml steps: diff --git a/.github/workflows/1-step.yml b/.github/workflows/1-step.yml index a846342c..f06a6f90 100644 --- a/.github/workflows/1-step.yml +++ b/.github/workflows/1-step.yml @@ -4,6 +4,8 @@ on: push: branches: - welcome-workflow + paths: + - ".github/**" permissions: contents: read diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml index e7a78dc1..12d91ee3 100644 --- a/.github/workflows/3-step.yml +++ b/.github/workflows/3-step.yml @@ -2,14 +2,8 @@ name: Step 3 on: push: - bra - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.5.0 - - - name: Update comment - checking work - welcome-workflow + branches: + - welcome-workflow paths: - ".github/workflows/welcome.yml" From 56534e13082dcbf941e3040971946214658674fa Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 13:18:54 +0200 Subject: [PATCH 08/13] Add screenshot to step1 --- .github/steps/1-step.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index ee448e6d..22bf4ae8 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -17,7 +17,8 @@ Workflows let you automate tasks like building, testing, or deploying your code, 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`. - + create branch screenshot + 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: From 45d2bb907b5f25118666ec0ed2025d3b63541436 Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 11:50:03 +0000 Subject: [PATCH 09/13] Test run updates --- .github/steps/1-step.md | 4 ++-- .github/steps/2-step.md | 2 +- .github/steps/3-step.md | 2 ++ .github/steps/4-step.md | 7 +++---- .github/steps/5-step.md | 2 +- .github/steps/x-review.md | 5 +---- .github/workflows/3-step.yml | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index 22bf4ae8..129d3f1d 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -2,7 +2,7 @@ Welcome to "Hello GitHub Actions" exercise! :wave: -### 📖 Theory: Introduction to workflows, workflow files, and event triggers +### 📖 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. @@ -13,7 +13,7 @@ Workflows let you automate tasks like building, testing, or deploying your code, > - [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 and open a 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`. diff --git a/.github/steps/2-step.md b/.github/steps/2-step.md index d410ca5c..816009ab 100644 --- a/.github/steps/2-step.md +++ b/.github/steps/2-step.md @@ -2,7 +2,7 @@ Nice work! :tada: You added a workflow file! -### 📖 Theory: Introduction to jobs in GitHub Actions workflows +### 📖 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. diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index 96d7ebe1..4d001b0d 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -25,6 +25,8 @@ Steps are the building blocks of jobs, allowing you to automate tasks like check 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! diff --git a/.github/steps/4-step.md b/.github/steps/4-step.md index 73e7d2c2..e97af463 100644 --- a/.github/steps/4-step.md +++ b/.github/steps/4-step.md @@ -2,17 +2,16 @@ _You've now added a fully functioning workflow to your repository! :smile:_ -The shell script in the workflow will run whenever a new pull request is opened. +### 📖 Theory: Seeing your workflow in action -### 📖 Theory: Seeing your action 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 that will merge `welcome-workflow` into `main`. -1. Watch the workflow running in the checks section of the pull request. +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. diff --git a/.github/steps/5-step.md b/.github/steps/5-step.md index ff1e7872..416a586c 100644 --- a/.github/steps/5-step.md +++ b/.github/steps/5-step.md @@ -1,4 +1,4 @@ -## Step 5: Merge your workflow and experiment +## Step 5: Merge and experiment _Great job! You have created and tested your first GitHub Actions workflow!_ :rocket: diff --git a/.github/steps/x-review.md b/.github/steps/x-review.md index 4c6b45e6..2b2dbc3b 100644 --- a/.github/steps/x-review.md +++ b/.github/steps/x-review.md @@ -13,9 +13,6 @@ Here's a recap of all the tasks you've accomplished in your repository: ### 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) -- [Discussion board](https://github.com/orgs/skills/discussions/categories/hello-github-actions) -- [Take another exercise](https://skills.github.com/#automate-workflows-with-github-actions) -- [Get started with GitHub](https://docs.github.com/get-started) -- [GitHub Explore](https://github.com/explore) diff --git a/.github/workflows/3-step.yml b/.github/workflows/3-step.yml index 12d91ee3..6ee9383e 100644 --- a/.github/workflows/3-step.yml +++ b/.github/workflows/3-step.yml @@ -95,7 +95,7 @@ jobs: step_number: 3 passed: ${{ !contains(steps.*.outcome, 'failure') }} results_table: - - description: "Workflow file passes actionlint syntax validation" + - description: "Workflow file syntax validation" passed: ${{ steps.actionlint-check.outcome == 'success' }} - description: "Added steps section to welcome job" passed: ${{ steps.check-steps-section.outcome == 'success' }} From c35cca10b86e54b4b76732b2601d216861840a5d Mon Sep 17 00:00:00 2001 From: Aleksander Fidelus <63016446+FidelusAleksander@users.noreply.github.com> Date: Wed, 28 May 2025 11:54:35 +0000 Subject: [PATCH 10/13] Update README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8e5cdec2..481d1bd9 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ _Create and run a GitHub Actions workflow._ Automation is key for streamlining your work processes, and [GitHub Actions](https://docs.github.com/actions) is the best way to supercharge your workflow. - **Who is this for**: Developers, DevOps engineers, students, managers, teams, GitHub users. -- **What you'll learn**: How to create workflow files, trigger workflows, and find workflow logs. -- **What you'll build**: An Actions workflow that will check emoji shortcode references in Markdown files. -- **Prerequisites**: In this exercise you will work with issues and pull requests, as well as edit files. We recommend you take the [Introduction to GitHub](https://github.com/skills/introduction-to-github) exercise first. -- **How long**: This exercise can be finished in less than two hours. +- **What you'll learn**: How to create GitHub Actions workflows, how to run them, and how to use them to automate tasks. +- **What you'll build**: An Actions workflow that will comment on a pull request when it is created. +- **Prerequisites**: If you are new to GitHub, we recommend you take the [Introduction to GitHub](https://github.com/skills/introduction-to-github) exercise first. +- **How long**: This exercise can be finished in less than 30min. In this exercise, you will: -1. Create a workflow +1. Create a workflow file 1. Add a job 1. Add a run step 1. Merge your pull request From 470fcbcc4fc01cddba0163037194e1374e5d0a8f Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Wed, 28 May 2025 13:58:02 -0500 Subject: [PATCH 11/13] Wording adjustments and including links from test run --- .github/steps/1-step.md | 15 ++++++++++----- .github/steps/2-step.md | 17 +++++++++-------- .github/steps/3-step.md | 35 +++++++++++++++++++++-------------- .github/steps/5-step.md | 9 ++++----- README.md | 10 +++++----- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/.github/steps/1-step.md b/.github/steps/1-step.md index 129d3f1d..8c39cd23 100644 --- a/.github/steps/1-step.md +++ b/.github/steps/1-step.md @@ -1,25 +1,26 @@ ## 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. +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#pull_request) +> - [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`. + create branch screenshot 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 @@ -31,8 +32,12 @@ Workflows let you automate tasks like building, testing, or deploying your code, 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. As you commit your changes Mona will prepare the next step in this exercise! + +1. With your workflow file committed, Mona will check your work and prepare the next step in this exercise!
Having trouble? 🤷
diff --git a/.github/steps/2-step.md b/.github/steps/2-step.md index 816009ab..7f5bca30 100644 --- a/.github/steps/2-step.md +++ b/.github/steps/2-step.md @@ -4,18 +4,18 @@ 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. +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. Each job can run on different environments and can be configured to run in parallel or sequentially. +Jobs help you organize your workflow into logical units, such as building, testing, or deploying your code. -> [!NOTE] -> -> - [Jobs in GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#jobs) +> [!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 a job section as shown below: + +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 @@ -30,8 +30,9 @@ Jobs help you organize your workflow into logical units, such as building, testi 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! +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!
Having trouble? 🤷
diff --git a/.github/steps/3-step.md b/.github/steps/3-step.md index 4d001b0d..88ff20bc 100644 --- a/.github/steps/3-step.md +++ b/.github/steps/3-step.md @@ -4,31 +4,38 @@ _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](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. -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) +> [!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 - 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 }} + 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 }} ``` - > ❗ **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! + +1. With the step information added, Mona will review your work and prepare the next step in this exercise!
Having trouble? 🤷
diff --git a/.github/steps/5-step.md b/.github/steps/5-step.md index 416a586c..8e46f4bb 100644 --- a/.github/steps/5-step.md +++ b/.github/steps/5-step.md @@ -4,17 +4,16 @@ _Great job! You have created and tested your first GitHub Actions workflow!_ :ro ### 📖 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. +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. -Once merged, every new pull request you open will automatically trigger the workflow you created. +Every new pull request regardless of branch will now 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. +> 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! diff --git a/README.md b/README.md index 481d1bd9..06a1b6b9 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ _Create and run a GitHub Actions workflow._ ## Welcome -Automation is key for streamlining your work processes, and [GitHub Actions](https://docs.github.com/actions) is the best way to supercharge your workflow. +Automation is key for repetitive tasks like testing, scanning, review, and deployment processes, and [GitHub Actions](https://docs.github.com/actions) is the best way to streamline that workflow. -- **Who is this for**: Developers, DevOps engineers, students, managers, teams, GitHub users. +- **Who is this for**: Developers, DevOps engineers, Security engineers - **What you'll learn**: How to create GitHub Actions workflows, how to run them, and how to use them to automate tasks. - **What you'll build**: An Actions workflow that will comment on a pull request when it is created. -- **Prerequisites**: If you are new to GitHub, we recommend you take the [Introduction to GitHub](https://github.com/skills/introduction-to-github) exercise first. +- **Prerequisites**: [Introduction to GitHub](https://github.com/skills/introduction-to-github) - **How long**: This exercise can be finished in less than 30min. In this exercise, you will: @@ -17,14 +17,14 @@ In this exercise, you will: 1. Create a workflow file 1. Add a job 1. Add a run step +1. See the workflow run 1. Merge your pull request -1. See effect of the workflow ### How to start this exercise Simply copy the exercise to your account, then give your favorite Octocat (Mona) **about 20 seconds** to prepare the first lesson, then **refresh the page**. -[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=FidelusAleksander&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=Exercise:Create+and+run+a+GitHub+Actions+Workflow&visibility=public) +[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=FidelusAleksander&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=Exercise:+Create+and+run+a+GitHub+Actions+Workflow&visibility=public)
Having trouble? 🤷
From 64c967bde9560ca427f9e0b787ae4b33d23a2812 Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Wed, 28 May 2025 13:58:28 -0500 Subject: [PATCH 12/13] Add optional step about viewing actions logs --- .github/steps/4-step.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/steps/4-step.md b/.github/steps/4-step.md index e97af463..c942ee6a 100644 --- a/.github/steps/4-step.md +++ b/.github/steps/4-step.md @@ -4,16 +4,35 @@ _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. -> [!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. +> [!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. +
Having trouble? 🤷
From 23d49e9924ee1fe5c32e3de2add4621e535a5640 Mon Sep 17 00:00:00 2001 From: "Christopher W. Blake" Date: Wed, 28 May 2025 14:00:16 -0500 Subject: [PATCH 13/13] Update url for copy exercise --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06a1b6b9..a7afc494 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ In this exercise, you will: Simply copy the exercise to your account, then give your favorite Octocat (Mona) **about 20 seconds** to prepare the first lesson, then **refresh the page**. -[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=FidelusAleksander&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=Exercise:+Create+and+run+a+GitHub+Actions+Workflow&visibility=public) +[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=skills&template_name=hello-github-actions&owner=%40me&name=skills-hello-github-actions&description=Exercise:+Create+and+run+a+GitHub+Actions+Workflow&visibility=public)
Having trouble? 🤷