├── .github
├── dependabot.yml
├── steps
│ ├── 1-step.md
│ ├── 2-step.md
│ ├── 3-step.md
│ ├── 4-step.md
│ ├── 5-step.md
│ └── x-review.md
└── workflows
│ ├── 0-start-exercise.yml
│ ├── 1-step.yml
│ ├── 2-step.yml
│ ├── 3-step.yml
│ ├── 4-step.yml
│ └── 5-step.yml
├── .gitignore
├── LICENSE
└── README.md
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "monthly"
7 |
--------------------------------------------------------------------------------
/.github/steps/1-step.md:
--------------------------------------------------------------------------------
1 | ## Step 1: Create a workflow file
2 |
3 | ### 📖 Theory: Introduction to workflows
4 |
5 | A **workflow** is an automated process that you define in your repository. Workflows are described in YAML files stored in the `.github/workflows` directory. Each workflow is triggered by specific [events](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows) happening in your repository such as opening a pull request, pushing code, or creating an issue.
6 |
7 | Workflows let you automate tasks like building, testing, or deploying your code, and can respond to almost any activity in your project.
8 |
9 | > [!NOTE]
10 | > If you want to learn more check out these resources:
11 | > - [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)
12 | > - [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows)
13 |
14 | ### ⌨️ Activity: Create a workflow file
15 |
16 | 1. Open this repository in a new browser tab so you can work on the steps while you read the instructions in this tab.
17 |
18 | 1. In the **Code** tab of your repository, create a new branch named `welcome-workflow`.
19 |
20 |
21 |
22 | 1. In the `welcome-workflow` branch, navigate to the `.github/workflows` directory.
23 |
24 | 1. Create a new file named `welcome.yml` in the `.github/workflows` directory with the following content:
25 |
26 | ```yaml
27 | name: Post welcome comment
28 | on:
29 | pull_request:
30 | types: [opened]
31 | permissions:
32 | pull-requests: write
33 | ```
34 |
35 | > [!NOTE]
36 | > This is an incomplete workflow file. It is normal if you receive an error message. One step at a time! 😎
37 |
38 | 1. Commit your changes directly to the `welcome-workflow` branch.
39 |
40 | 1. With your workflow file committed, Mona will check your work and prepare the next step in this exercise!
41 |
42 |
43 | Having trouble? 🤷
44 |
45 | - Make sure you are on the `welcome-workflow` branch when creating the workflow file.
46 | - Double-check the file path and YAML indentation.
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.github/steps/2-step.md:
--------------------------------------------------------------------------------
1 | ## Step 2: Add a job to your workflow file
2 |
3 | Nice work! :tada: You added a workflow file!
4 |
5 | ### 📖 Theory: Introduction to jobs
6 |
7 | A [job](https://docs.github.com/en/actions/about-github-actions/understanding-github-actions#jobs) is a group of steps that run together on the same [runner](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners) within a workflow. Each job is defined under the `jobs` section and runs independently and in parallel by default.
8 |
9 | Jobs help you organize your workflow into logical units, such as building, testing, or deploying your code.
10 |
11 | > [!Tip]
12 | > You can define a job to run with multiple [variations using a matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow).
13 |
14 | ### ⌨️ Activity: Add a job to your workflow file
15 |
16 | 1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.
17 |
18 | 1. Edit the file to add the `jobs` section and 1 job named `welcome`, which will run on the latest Ubuntu operating system.
19 |
20 | ```yaml
21 | name: Post welcome comment
22 | on:
23 | pull_request:
24 | types: [opened]
25 | permissions:
26 | pull-requests: write
27 | jobs:
28 | welcome:
29 | name: Post welcome comment
30 | runs-on: ubuntu-latest
31 | ```
32 |
33 | 1. Commit your changes to the `welcome-workflow` branch.
34 |
35 | 1. With the job information added, Mona will review your work and prepare the next step in this exercise!
36 |
37 |
38 | Having trouble? 🤷
39 |
40 | - Make sure the `jobs` section is properly indented in your YAML file.
41 | - Confirm you are editing the correct file and branch.
42 |
43 |
44 |
--------------------------------------------------------------------------------
/.github/steps/3-step.md:
--------------------------------------------------------------------------------
1 | ## Step 3: Add a step to your workflow file
2 |
3 | _Nice work adding a job to your workflow! :dancer:_
4 |
5 | ### 📖 Theory: Introduction to steps in jobs
6 |
7 | [Steps](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idsteps) are the building blocks of jobs, allowing you to automate tasks like checking out code, running commands, or using open source Actions. They run sequentially in the job's environment but as independent processes. Unlike traditional code with a shared variable space, [inputs](https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#inputs) and [outputs](https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputs-for-docker-container-and-javascript-actions) must be explicitly declared.
8 |
9 | > [!TIP]
10 | > The best part of GitHub Actions is the [marketplace](https://github.com/marketplace?type=actions) where the community has already built many free useful tools to [find and customize](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-pre-written-building-blocks-in-your-workflow)!
11 |
12 | ### ⌨️ Activity: Add a step to your workflow file
13 |
14 | 1. In the `welcome-workflow` branch, open your `.github/workflows/welcome.yml` file.
15 |
16 | 1. Add a step to the `welcome` job to post a comment on new pull requests using GitHub CLI:
17 |
18 | ```yaml
19 | name: Post welcome comment
20 | on:
21 | pull_request:
22 | types: [opened]
23 | permissions:
24 | pull-requests: write
25 | jobs:
26 | welcome:
27 | name: Post welcome comment
28 | runs-on: ubuntu-latest
29 | steps:
30 | - run: gh pr comment "$PR_URL" --body "Welcome to the repository!"
31 | env:
32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 | PR_URL: ${{ github.event.pull_request.html_url }}
34 | ```
35 |
36 | 1. Commit your changes directly to `welcome-workflow` branch.
37 |
38 | 1. With the step information added, Mona will review your work and prepare the next step in this exercise!
39 |
40 |
41 | Having trouble? 🤷
42 |
43 | - Make sure the `steps` section is under the `welcome` job and properly indented.
44 | - Ensure you have the correct environment variables set.
45 |
46 |
47 |
--------------------------------------------------------------------------------
/.github/steps/4-step.md:
--------------------------------------------------------------------------------
1 | ## Step 4: Trigger the workflow
2 |
3 | _You've now added a fully functioning workflow to your repository! :smile:_
4 |
5 | ### 📖 Theory: Seeing your workflow in action
6 |
7 | All the running and finished workflows can be seen on the **Actions** tab of your repository.
8 |
9 | Because you set the workflow to run on the `pull_request` event, it will automatically trigger when a pull request is opened.
10 |
11 | > [!TIP]
12 | > Workflow associated to pull request can also be seen on the pull request log near the merge button. You can even [create a rule](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#require-status-checks-to-pass-before-merging) that prevents merging if the workflow fails!
13 |
14 | ### ⌨️ Activity: Trigger the workflow
15 |
16 | 1. In the **Pull requests** tab, create a pull request from `welcome-workflow` branch into `main`.
17 |
18 | 1. Notice the comment that the workflow adds to the pull request.
19 |
20 | 1. Notice the area near the merge button that "All checks have passed".
21 |
22 | 1. With the pull request created and our workflow triggered, Mona will prepare the next step in this exercise!
23 |
24 | ### ⌨️ Activity: (optional) Inspect the workflow
25 |
26 | 1. At the top of the repository, select the **Actions** tab.
27 |
28 | 1. In the left sidebar, select the workflow named **Post welcome comment**.
29 |
30 | > 💡 **Tip:** You can ignore the other actions. Those were for teaching this exercise.
31 |
32 | 1. Click the first run entry titled **Welcome workflow** to show a diagram of the run's jobs.
33 |
34 | 1. Click on the job named **Post welcome comment** to see the full logs.
35 |
36 |
37 |
38 | Having trouble? 🤷
39 |
40 | - Check the **Actions** tab for workflow run details and errors.
41 |
42 |
43 |
--------------------------------------------------------------------------------
/.github/steps/5-step.md:
--------------------------------------------------------------------------------
1 | ## Step 5: Merge and experiment
2 |
3 | _Great job! You have created and tested your first GitHub Actions workflow!_ :rocket:
4 |
5 | ### 📖 Theory: When workflows run
6 |
7 | 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.
8 |
9 | Every new pull request regardless of branch will now automatically trigger the workflow you created.
10 |
11 | > [!TIP]
12 | > 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.
13 |
14 | ### ⌨️ Activity: Merging your pull request
15 |
16 | 1. Merge your pull request into the `main` branch.
17 |
18 | 1. (Optional) Try opening another pull request to see your workflow run again!
19 |
20 |
--------------------------------------------------------------------------------
/.github/steps/x-review.md:
--------------------------------------------------------------------------------
1 | ## Finish
2 |
3 | _Congratulations friend, you've completed this exercise!_
4 |
5 |
6 |
7 | Here's a recap of all the tasks you've accomplished in your repository:
8 |
9 | 1. You've created your first GitHub Actions workflow file.
10 | 1. You learned where to make your workflow file.
11 | 1. You defined an event trigger, a job, and a step for your workflow.
12 | 1. You're ready to automate anything you can dream of.
13 |
14 | ### What's next?
15 |
16 | - [Take another exercise](https://skills.github.com/)
17 | - [Learn more about GitHub Actions](https://docs.github.com/actions/)
18 | - [Awesome Actions](https://github.com/sdras/awesome-actions)
19 |
--------------------------------------------------------------------------------
/.github/workflows/0-start-exercise.yml:
--------------------------------------------------------------------------------
1 | name: Step 0 # Start Exercise
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | permissions:
9 | contents: write
10 | actions: write
11 | issues: write
12 |
13 | env:
14 | STEP_1_FILE: ".github/steps/1-step.md"
15 |
16 | jobs:
17 | start_exercise:
18 | name: Start Exercise
19 | uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.5.0
20 | with:
21 | exercise-title: "Hello GitHub Actions"
22 | intro-message: "Create and run a GitHub Actions workflow."
23 |
24 | post_next_step_content:
25 | name: Post next step content
26 | runs-on: ubuntu-latest
27 | needs: [start_exercise]
28 | env:
29 | ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
30 | steps:
31 | - name: Checkout
32 | uses: actions/checkout@v4
33 | - name: Get response templates
34 | uses: actions/checkout@v4
35 | with:
36 | repository: skills/exercise-toolkit
37 | path: exercise-toolkit
38 | ref: v0.5.0
39 | - name: Build comment - add step content
40 | id: build-comment
41 | uses: skills/action-text-variables@v2
42 | with:
43 | template-file: ${{ env.STEP_1_FILE }}
44 | template-vars: |
45 | login: ${{ github.actor }}
46 | full_repo_name: ${{ github.repository }}
47 | - name: Create comment - add step content
48 | run: |
49 | gh issue comment "$ISSUE_URL" \
50 | --body "$ISSUE_BODY"
51 | env:
52 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 | ISSUE_BODY: ${{ steps.build-comment.outputs.updated-text }}
54 | - name: Create comment - watching for progress
55 | run: |
56 | gh issue comment "$ISSUE_URL" \
57 | --body-file "exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md"
58 | env:
59 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 | - name: Enable next step workflow
61 | run: |
62 | gh workflow enable "Step 1"
63 | env:
64 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65 |
--------------------------------------------------------------------------------
/.github/workflows/1-step.yml:
--------------------------------------------------------------------------------
1 | name: Step 1
2 |
3 | on:
4 | push:
5 | branches:
6 | - welcome-workflow
7 | paths:
8 | - ".github/**"
9 |
10 | permissions:
11 | contents: read
12 | actions: write
13 | issues: write
14 |
15 | env:
16 | STEP_2_FILE: ".github/steps/2-step.md"
17 |
18 | jobs:
19 | find_exercise:
20 | name: Find Exercise Issue
21 | uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
22 |
23 | check_step_work:
24 | name: Check step work
25 | runs-on: ubuntu-latest
26 | needs: [find_exercise]
27 | env:
28 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
29 |
30 | steps:
31 | - name: Checkout
32 | uses: actions/checkout@v4
33 |
34 | - name: Get response templates
35 | uses: actions/checkout@v4
36 | with:
37 | repository: skills/exercise-toolkit
38 | path: exercise-toolkit
39 | ref: v0.5.0
40 |
41 | - name: Update comment - checking work
42 | run: |
43 | gh issue comment "$ISSUE_URL" \
44 | --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \
45 | --edit-last
46 | env:
47 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 |
49 | - name: Check if welcome.yml file exists
50 | id: check-file-exists
51 | continue-on-error: true
52 | uses: skills/exercise-toolkit/actions/file-exists@v0.5.0
53 | with:
54 | file: .github/workflows/welcome.yml
55 |
56 | - name: Check for workflow name in welcome.yml
57 | id: check-workflow-name
58 | continue-on-error: true
59 | uses: skills/action-keyphrase-checker@v1
60 | with:
61 | text-file: .github/workflows/welcome.yml
62 | keyphrase: "name:"
63 |
64 | - name: Check for pull_request event in welcome.yml
65 | id: check-pull-request-event
66 | continue-on-error: true
67 | uses: skills/action-keyphrase-checker@v1
68 | with:
69 | text-file: .github/workflows/welcome.yml
70 | keyphrase: "pull_request:"
71 |
72 | - name: Check for types filter
73 | id: check-opened-type
74 | continue-on-error: true
75 | uses: skills/action-keyphrase-checker@v1
76 | with:
77 | text-file: .github/workflows/welcome.yml
78 | keyphrase: "types:"
79 |
80 | - name: Check for permissions in welcome.yml
81 | id: check-permissions
82 | continue-on-error: true
83 | uses: skills/action-keyphrase-checker@v1
84 | with:
85 | text-file: .github/workflows/welcome.yml
86 | keyphrase: "pull-requests: write"
87 |
88 | - name: Build message - step results
89 | id: build-message-step-results
90 | uses: skills/action-text-variables@v2
91 | with:
92 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md
93 | template-vars: |
94 | step_number: 1
95 | passed: ${{ !contains(steps.*.outcome, 'failure') }}
96 | results_table:
97 | - description: "Created welcome.yml file in .github/workflows directory"
98 | passed: ${{ steps.check-file-exists.outcome == 'success' }}
99 | - description: "Added a workflow name field"
100 | passed: ${{ steps.check-workflow-name.outcome == 'success' }}
101 | - description: "Configured pull_request event trigger"
102 | passed: ${{ steps.check-pull-request-event.outcome == 'success' }}
103 | - description: "Set types filter for pull_request event"
104 | passed: ${{ steps.check-opened-type.outcome == 'success' }}
105 | - description: "Added pull-requests: write permission"
106 | passed: ${{ steps.check-permissions.outcome == 'success' }}
107 |
108 | - name: Create comment - step results
109 | run: |
110 | gh issue comment "$ISSUE_URL" \
111 | --body "$COMMENT_BODY" \
112 | --edit-last
113 | env:
114 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115 | COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }}
116 |
117 | - name: Fail job if not all checks passed
118 | if: contains(steps.*.outcome, 'failure')
119 | run: exit 1
120 |
121 | - name: Build message - step finished
122 | id: build-message-step-finish
123 | uses: skills/action-text-variables@v2
124 | with:
125 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
126 | template-vars: |
127 | next_step_number: 2
128 |
129 | - name: Update comment - step finished
130 | run: |
131 | gh issue comment "$ISSUE_URL" \
132 | --body "$ISSUE_BODY"
133 | env:
134 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135 | ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }}
136 |
137 | post_next_step_content:
138 | name: Post next step content
139 | needs: [find_exercise, check_step_work]
140 | runs-on: ubuntu-latest
141 | env:
142 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
143 | steps:
144 | - name: Checkout
145 | uses: actions/checkout@v4
146 | - name: Get response templates
147 | uses: actions/checkout@v4
148 | with:
149 | repository: skills/exercise-toolkit
150 | path: exercise-toolkit
151 | ref: v0.5.0
152 | - name: Create comment - add step content
153 | run: |
154 | gh issue comment "$ISSUE_URL" \
155 | --body-file "$STEP_2_FILE"
156 | env:
157 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158 | - name: Create comment - watching for progress
159 | run: |
160 | gh issue comment "$ISSUE_URL" \
161 | --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
162 | env:
163 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164 | - name: Disable current workflow and enable next one
165 | run: |
166 | gh workflow disable "${{github.workflow}}"
167 | gh workflow enable "Step 2"
168 | env:
169 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170 |
--------------------------------------------------------------------------------
/.github/workflows/2-step.yml:
--------------------------------------------------------------------------------
1 | name: Step 2
2 |
3 | on:
4 | push:
5 | branches:
6 | - welcome-workflow
7 |
8 | permissions:
9 | contents: write
10 | actions: write
11 | issues: write
12 |
13 | env:
14 | STEP_3_FILE: ".github/steps/3-step.md"
15 |
16 | jobs:
17 | find_exercise:
18 | name: Find Exercise Issue
19 | uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
20 |
21 | check_step_work:
22 | name: Check step work
23 | runs-on: ubuntu-latest
24 | needs: [find_exercise]
25 | env:
26 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
27 |
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@v4
31 |
32 | - name: Get response templates
33 | uses: actions/checkout@v4
34 | with:
35 | repository: skills/exercise-toolkit
36 | path: exercise-toolkit
37 | ref: v0.5.0
38 |
39 | - name: Update comment - checking work
40 | run: |
41 | gh issue comment "$ISSUE_URL" \
42 | --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \
43 | --edit-last
44 | env:
45 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 |
47 | - name: Check for jobs section in welcome.yml
48 | id: check-jobs-section
49 | continue-on-error: true
50 | uses: skills/action-keyphrase-checker@v1
51 | with:
52 | text-file: .github/workflows/welcome.yml
53 | keyphrase: "jobs:"
54 |
55 | - name: Check for welcome job in welcome.yml
56 | id: check-welcome-job
57 | continue-on-error: true
58 | uses: skills/action-keyphrase-checker@v1
59 | with:
60 | text-file: .github/workflows/welcome.yml
61 | keyphrase: "welcome:"
62 |
63 | - name: Check for runs-on ubuntu-latest in welcome.yml
64 | id: check-runs-on
65 | continue-on-error: true
66 | uses: skills/action-keyphrase-checker@v1
67 | with:
68 | text-file: .github/workflows/welcome.yml
69 | keyphrase: "runs-on: ubuntu-latest"
70 |
71 | - name: Build message - step results
72 | id: build-message-step-results
73 | uses: skills/action-text-variables@v2
74 | with:
75 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md
76 | template-vars: |
77 | step_number: 2
78 | passed: ${{ !contains(steps.*.outcome, 'failure') }}
79 | results_table:
80 | - description: "Added jobs section to workflow file"
81 | passed: ${{ steps.check-jobs-section.outcome == 'success' }}
82 | - description: "Created welcome job"
83 | passed: ${{ steps.check-welcome-job.outcome == 'success' }}
84 | - description: "Set runs-on to ubuntu-latest"
85 | passed: ${{ steps.check-runs-on.outcome == 'success' }}
86 |
87 | - name: Create comment - step results
88 | run: |
89 | gh issue comment "$ISSUE_URL" \
90 | --body "$COMMENT_BODY" \
91 | --edit-last
92 | env:
93 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94 | COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }}
95 |
96 | - name: Fail job if not all checks passed
97 | if: contains(steps.*.outcome, 'failure')
98 | run: exit 1
99 |
100 | - name: Build message - step finished
101 | id: build-message-step-finish
102 | uses: skills/action-text-variables@v2
103 | with:
104 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
105 | template-vars: |
106 | next_step_number: 3
107 |
108 | - name: Update comment - step finished
109 | run: |
110 | gh issue comment "$ISSUE_URL" \
111 | --body "$ISSUE_BODY"
112 | env:
113 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114 | ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }}
115 |
116 | post_next_step_content:
117 | name: Post next step content
118 | needs: [find_exercise, check_step_work]
119 | runs-on: ubuntu-latest
120 | env:
121 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
122 | steps:
123 | - name: Checkout
124 | uses: actions/checkout@v4
125 | - name: Get response templates
126 | uses: actions/checkout@v4
127 | with:
128 | repository: skills/exercise-toolkit
129 | path: exercise-toolkit
130 | ref: v0.5.0
131 | - name: Create comment - add step content
132 | run: |
133 | gh issue comment "$ISSUE_URL" \
134 | --body-file "$STEP_3_FILE"
135 | env:
136 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137 | - name: Create comment - watching for progress
138 | run: |
139 | gh issue comment "$ISSUE_URL" \
140 | --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
141 | env:
142 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143 | - name: Disable current workflow and enable next one
144 | run: |
145 | gh workflow disable "${{github.workflow}}"
146 | gh workflow enable "Step 3"
147 | env:
148 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149 |
--------------------------------------------------------------------------------
/.github/workflows/3-step.yml:
--------------------------------------------------------------------------------
1 | name: Step 3
2 |
3 | on:
4 | push:
5 | branches:
6 | - welcome-workflow
7 | paths:
8 | - ".github/workflows/welcome.yml"
9 |
10 | permissions:
11 | contents: read
12 | actions: write
13 | issues: write
14 |
15 | env:
16 | STEP_4_FILE: ".github/steps/4-step.md"
17 |
18 | jobs:
19 | find_exercise:
20 | name: Find Exercise Issue
21 | uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
22 |
23 | check_step_work:
24 | name: Check step work
25 | runs-on: ubuntu-latest
26 | needs: [find_exercise]
27 | env:
28 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
29 |
30 | steps:
31 | - name: Checkout
32 | uses: actions/checkout@v4
33 |
34 | - name: Get response templates
35 | uses: actions/checkout@v4
36 | with:
37 | repository: skills/exercise-toolkit
38 | path: exercise-toolkit
39 | ref: v0.5.0
40 |
41 | - name: Update comment - checking work
42 | run: |
43 | gh issue comment "$ISSUE_URL" \
44 | --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \
45 | --edit-last
46 | env:
47 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 |
49 | - name: Lint welcome.yml with actionlint
50 | id: actionlint-check
51 | continue-on-error: true
52 | uses: raven-actions/actionlint@01fce4f43a270a612932cb1c64d40505a029f821 # v2.0.0
53 | with:
54 | files: .github/workflows/welcome.yml
55 |
56 | - name: Check for steps section in welcome.yml
57 | id: check-steps-section
58 | continue-on-error: true
59 | uses: skills/action-keyphrase-checker@v1
60 | with:
61 | text-file: .github/workflows/welcome.yml
62 | keyphrase: "steps:"
63 | fail-on-error: true
64 |
65 | - name: Check for gh pr comment command in welcome.yml
66 | id: check-gh-pr-comment
67 | continue-on-error: true
68 | uses: skills/action-keyphrase-checker@v1
69 | with:
70 | text-file: .github/workflows/welcome.yml
71 | keyphrase: "gh pr comment"
72 |
73 | - name: Check for GITHUB_TOKEN env var in welcome.yml
74 | id: check-github-token
75 | continue-on-error: true
76 | uses: skills/action-keyphrase-checker@v1
77 | with:
78 | text-file: .github/workflows/welcome.yml
79 | keyphrase: "GITHUB_TOKEN:"
80 |
81 | - name: Check for PR_URL env var in welcome.yml
82 | id: check-pr-url
83 | continue-on-error: true
84 | uses: skills/action-keyphrase-checker@v1
85 | with:
86 | text-file: .github/workflows/welcome.yml
87 | keyphrase: "PR_URL:"
88 |
89 | - name: Build message - step results
90 | id: build-message-step-results
91 | uses: skills/action-text-variables@v2
92 | with:
93 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md
94 | template-vars: |
95 | step_number: 3
96 | passed: ${{ !contains(steps.*.outcome, 'failure') }}
97 | results_table:
98 | - description: "Workflow file syntax validation"
99 | passed: ${{ steps.actionlint-check.outcome == 'success' }}
100 | - description: "Added steps section to welcome job"
101 | passed: ${{ steps.check-steps-section.outcome == 'success' }}
102 | - description: "Added gh pr comment command"
103 | passed: ${{ steps.check-gh-pr-comment.outcome == 'success' }}
104 | - description: "Set GITHUB_TOKEN environment variable"
105 | passed: ${{ steps.check-github-token.outcome == 'success' }}
106 | - description: "Set PR_URL environment variable"
107 | passed: ${{ steps.check-pr-url.outcome == 'success' }}
108 |
109 | - name: Create comment - step results
110 | run: |
111 | gh issue comment "$ISSUE_URL" \
112 | --body "$COMMENT_BODY" \
113 | --edit-last
114 | env:
115 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116 | COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }}
117 |
118 | - name: Fail job if not all checks passed
119 | if: contains(steps.*.outcome, 'failure')
120 | run: exit 1
121 |
122 | - name: Build message - step finished
123 | id: build-message-step-finish
124 | uses: skills/action-text-variables@v2
125 | with:
126 | template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
127 | template-vars: |
128 | next_step_number: 4
129 |
130 | - name: Update comment - step finished
131 | run: |
132 | gh issue comment "$ISSUE_URL" \
133 | --body "$ISSUE_BODY"
134 | env:
135 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136 | ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }}
137 |
138 | post_next_step_content:
139 | name: Post next step content
140 | needs: [find_exercise, check_step_work]
141 | runs-on: ubuntu-latest
142 | env:
143 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
144 | steps:
145 | - name: Checkout
146 | uses: actions/checkout@v4
147 | - name: Get response templates
148 | uses: actions/checkout@v4
149 | with:
150 | repository: skills/exercise-toolkit
151 | path: exercise-toolkit
152 | ref: v0.5.0
153 | - name: Create comment - add step content
154 | run: |
155 | gh issue comment "$ISSUE_URL" \
156 | --body-file "$STEP_4_FILE"
157 | env:
158 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159 | - name: Create comment - watching for progress
160 | run: |
161 | gh issue comment "$ISSUE_URL" \
162 | --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
163 | env:
164 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165 | - name: Disable current workflow and enable next one
166 | run: |
167 | gh workflow disable "${{github.workflow}}"
168 | gh workflow enable "Step 4"
169 | env:
170 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171 |
--------------------------------------------------------------------------------
/.github/workflows/4-step.yml:
--------------------------------------------------------------------------------
1 | name: Step 4
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | types:
8 | - opened
9 |
10 | permissions:
11 | contents: write
12 | actions: write
13 | issues: write
14 |
15 | env:
16 | STEP_5_FILE: ".github/steps/5-step.md"
17 |
18 | jobs:
19 | find_exercise:
20 | name: Find Exercise Issue
21 | uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
22 |
23 | post_next_step_content:
24 | name: Post next step content
25 | needs: [find_exercise]
26 | runs-on: ubuntu-latest
27 | env:
28 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
29 | steps:
30 | - name: Checkout
31 | uses: actions/checkout@v4
32 | - name: Get response templates
33 | uses: actions/checkout@v4
34 | with:
35 | repository: skills/exercise-toolkit
36 | path: exercise-toolkit
37 | ref: v0.5.0
38 | - name: Create comment - add step content
39 | run: |
40 | gh issue comment "$ISSUE_URL" \
41 | --body-file "$STEP_5_FILE"
42 | env:
43 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 | - name: Create comment - watching for progress
45 | run: |
46 | gh issue comment "$ISSUE_URL" \
47 | --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
48 | env:
49 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 | - name: Disable current workflow and enable next one
51 | run: |
52 | gh workflow disable "${{github.workflow}}"
53 | gh workflow enable "Step 5"
54 | env:
55 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 |
--------------------------------------------------------------------------------
/.github/workflows/5-step.yml:
--------------------------------------------------------------------------------
1 | name: Step 5
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | types:
8 | - closed
9 |
10 | permissions:
11 | contents: write
12 | actions: write
13 | issues: write
14 |
15 | env:
16 | REVIEW_FILE: ".github/steps/x-review.md"
17 |
18 | jobs:
19 | find_exercise:
20 | name: Find Exercise Issue
21 | uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
22 |
23 | post_review_content:
24 | name: Post review content
25 | needs: [find_exercise]
26 | runs-on: ubuntu-latest
27 | env:
28 | ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
29 | steps:
30 | - name: Checkout
31 | uses: actions/checkout@v4
32 | - name: Create comment - add step content
33 | run: |
34 | gh issue comment "$ISSUE_URL" \
35 | --body-file "$REVIEW_FILE"
36 | env:
37 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 | finish_exercise:
39 | name: Finish Exercise
40 | needs: [find_exercise, post_review_content]
41 | uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.5.0
42 | with:
43 | issue-url: ${{ needs.find_exercise.outputs.issue-url }}
44 | disable_workflow:
45 | name: Disable this workflow
46 | needs: [find_exercise, post_review_content]
47 | runs-on: ubuntu-latest
48 | steps:
49 | - name: Checkout
50 | uses: actions/checkout@v4
51 | - name: Disable current workflow
52 | run: gh workflow disable "${{github.workflow}}"
53 | env:
54 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled source #
2 | ###################
3 | *.com
4 | *.class
5 | *.dll
6 | *.exe
7 | *.o
8 | *.so
9 |
10 | # Packages #
11 | ############
12 | # it's better to unpack these files and commit the raw source
13 | # git has its own built in compression methods
14 | *.7z
15 | *.dmg
16 | *.gz
17 | *.iso
18 | *.jar
19 | *.rar
20 | *.tar
21 | *.zip
22 |
23 | # Logs and databases #
24 | ######################
25 | *.log
26 | *.sql
27 | *.sqlite
28 |
29 | # OS generated files #
30 | ######################
31 | .DS_Store
32 | .DS_Store?
33 | ._*
34 | .Spotlight-V100
35 | .Trashes
36 | ehthumbs.db
37 | Thumbs.db
38 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) GitHub, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Hello GitHub Actions
2 |
3 | _Create and run a GitHub Actions workflow._
4 |
5 | ## Welcome
6 |
7 | 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.
8 |
9 | - **Who is this for**: Developers, DevOps engineers, Security engineers
10 | - **What you'll learn**: How to create GitHub Actions workflows, how to run them, and how to use them to automate tasks.
11 | - **What you'll build**: An Actions workflow that will comment on a pull request when it is created.
12 | - **Prerequisites**: [Introduction to GitHub](https://github.com/skills/introduction-to-github)
13 | - **How long**: This exercise can be finished in less than 30min.
14 |
15 | In this exercise, you will:
16 |
17 | 1. Create a workflow file
18 | 1. Add a job
19 | 1. Add a run step
20 | 1. See the workflow run
21 | 1. Merge your pull request
22 |
23 | ### How to start this exercise
24 |
25 | 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**.
26 |
27 | [](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)
28 |
29 |
30 | Having trouble? 🤷
31 |
32 | When copying the exercise, we recommend the following settings:
33 |
34 | - For owner, choose your personal account or an organization to host the repository.
35 |
36 | - We recommend creating a public repository, since private repositories will use Actions minutes.
37 |
38 | If the exercise isn't ready in 20 seconds, please check the [Actions](../../actions) tab.
39 |
40 | - Check to see if a job is running. Sometimes it simply takes a bit longer.
41 |
42 | - If the page shows a failed job, please submit an issue. Nice, you found a bug! 🐛
43 |
44 |
45 |
46 | ---
47 |
48 | © 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)
49 |
--------------------------------------------------------------------------------