Skip to content

Commit b41d7d7

Browse files
GeekTrainerCopilot
andcommitted
Add code scanning module, renumber exercises, and improve workshop flow
Add new exercise 2 (Securing the Development Pipeline) covering Dependabot, secret scanning, and code scanning. Includes callouts connecting code scanning to GitHub Actions, and a Dependabot note bridging to the CI exercise. Renumber exercises 2-8 to 3-9 and update all cross-references. Additional improvements across all exercises: - Add codespace and terminal callouts at context-switch points - Rename ci.yml to run-tests.yml with display name 'Run Tests' - Rename CD workflow display name to 'Deploy App' - Add 'Open your codespace' section to exercise 0 - Update exercise 3 intro to flow from code scanning module Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 05ca731 commit b41d7d7

13 files changed

Lines changed: 763 additions & 643 deletions

content/github-actions/0-setup.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,38 @@ Let's create the repository you'll use for your workshop.
1414
1. Navigate to [the repository root][repo-root]
1515
2. Select **Use this template** > **Create a new repository**
1616

17-
![Screenshot of Use this template dropdown](../images/setup-use-template.png)
17+
![Screenshot of Use this template dropdown](../shared-images/setup-use-template.png)
1818

1919
3. Under **Owner**, select the name of your GitHub handle, or the owner specified by your workshop leader.
2020
4. Under **Repository**, set the name to **pets-workshop**, or the name specified by your workshop leader.
2121
5. Ensure **Public** is selected for the visibility, or the value indicated by your workshop leader.
2222
6. Select **Create repository from template**.
2323

24-
![Screenshot of configured template creation dialog](../images/setup-configure-repo.png)
24+
![Screenshot of configured template creation dialog](../shared-images/setup-configure-repo.png)
2525

2626
In a few moments a new repository will be created from the template for this workshop!
2727

28+
## Open your codespace
29+
30+
Now let's open a codespace so you have a development environment ready to go.
31+
32+
1. Navigate to the main page of your newly created repository.
33+
2. Select **Code** > **Codespaces** > **Create codespace on main**.
34+
35+
In a few moments a codespace will open in your browser with a full VS Code editor. This is where you'll create and edit files throughout the workshop.
36+
37+
> [!TIP]
38+
> If your codespace ever disconnects or you close the tab, you can reopen it by navigating to your repository and selecting **Code** > **Codespaces** and the name of your codespace.
39+
2840
## Summary and next steps
2941

30-
You've now created the repository you'll use for this workshop! Next let's [create your first workflow][walkthrough-next].
42+
You've created the repository and opened a codespace — you're ready to start building! Next let's [create your first workflow][walkthrough-next].
3143

3244
| [← GitHub Actions: From CI to CD][walkthrough-previous] | [Next: Introduction & Your First Workflow →][walkthrough-next] |
3345
|:-----------------------------------|------------------------------------------:|
3446

35-
[fork-repo]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
36-
[template-repo]: https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository
47+
[fork-repo]: https://docs.github.com/get-started/quickstart/fork-a-repo
48+
[template-repo]: https://docs.github.com/repositories/creating-and-managing-repositories/creating-a-template-repository
3749
[repo-root]: /
3850
[walkthrough-previous]: README.md
3951
[walkthrough-next]: 1-introduction.md

content/github-actions/1-introduction.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction & Your First Workflow
22

3-
| [← Workshop Setup][walkthrough-previous] | [Next: Running Tests][walkthrough-next] |
3+
| [← Workshop Setup][walkthrough-previous] | [Next: Securing the Development Pipeline][walkthrough-next] |
44
|:-----------------------------------|------------------------------------------:|
55

66
[GitHub Actions][github-actions] is an automation platform built into GitHub that lets you build, test, and deploy your code directly from your repository. While it's most commonly used for CI/CD, it can automate just about any task in your development workflow — from labeling issues to resizing images.
@@ -18,7 +18,7 @@ Before diving in, here are the key terms you'll encounter:
1818

1919
The shelter has built its application — a Flask API and Astro frontend — and the team is ready to start automating their development workflow. Before diving into CI/CD, let's start with the basics: creating a simple workflow, triggering it manually, and understanding the logs.
2020

21-
## Understanding GitHub Actions
21+
## Background
2222

2323
A workflow file is written in YAML and lives in the `.github/workflows/` directory. Here are the core sections you'll work with:
2424

@@ -34,7 +34,7 @@ A workflow file is written in YAML and lives in the `.github/workflows/` directo
3434

3535
Let's start with the classic "Hello World" — a workflow you can trigger manually from the GitHub UI.
3636

37-
1. In your repository, create the folder `.github/workflows/` if it doesn't already exist.
37+
1. In your codespace, create the folder `.github/workflows/` if it doesn't already exist.
3838
2. Create a new file named `.github/workflows/hello.yml`.
3939
3. Add the following content:
4040

@@ -68,22 +68,23 @@ Let's start with the classic "Hello World" — a workflow you can trigger manual
6868

6969
Now let's push the workflow and trigger it by hand.
7070

71-
1. Stage and commit your changes:
71+
1. Open the terminal in your codespace by pressing <kbd>Ctl</kbd>+<kbd>`</kbd>.
72+
2. Stage and commit your changes:
7273

7374
```bash
7475
git add .github/workflows/hello.yml
7576
git commit -m "Add hello world workflow"
7677
```
7778

78-
2. Push to your repository:
79+
3. Push to your repository:
7980

8081
```bash
8182
git push
8283
```
8384

84-
3. Navigate to your repository on GitHub and select the **Actions** tab.
85-
4. In the left sidebar, select the **Hello World** workflow.
86-
5. Select the **Run workflow** button, keep the default branch, and select **Run workflow** again to confirm.
85+
4. Navigate to your repository on GitHub and select the **Actions** tab.
86+
5. In the left sidebar, select the **Hello World** workflow.
87+
6. Select the **Run workflow** button, keep the default branch, and select **Run workflow** again to confirm.
8788

8889
## Explore the logs
8990

@@ -103,7 +104,7 @@ Once the run completes, let's explore what happened.
103104

104105
Congratulations! You've created and run your first GitHub Actions workflow. You've learned how to define a workflow in YAML, trigger it manually with `workflow_dispatch`, and navigate the logs in the Actions UI.
105106

106-
Next, we'll put this knowledge to work by [building a CI workflow][walkthrough-next] that automatically tests the shelter's application.
107+
Next, we'll put this knowledge to work by [securing the development pipeline][walkthrough-next] with code scanning, Dependabot, and secret scanning.
107108

108109
### Resources
109110

@@ -112,14 +113,14 @@ Next, we'll put this knowledge to work by [building a CI workflow][walkthrough-n
112113
- [Events that trigger workflows][workflow-triggers]
113114
- [Understanding GitHub Actions][understanding-actions]
114115

115-
| [← Workshop Setup][walkthrough-previous] | [Next: Running Tests →][walkthrough-next] |
116+
| [← Workshop Setup][walkthrough-previous] | [Next: Securing the Development Pipeline →][walkthrough-next] |
116117
|:-----------------------------------|------------------------------------------:|
117118

118119
[actions-marketplace]: https://github.com/marketplace?type=actions
119120
[github-actions]: https://github.com/features/actions
120-
[github-actions-docs]: https://docs.github.com/en/actions
121-
[understanding-actions]: https://docs.github.com/en/actions/about-github-actions/understanding-github-actions
122-
[workflow-syntax]: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
123-
[workflow-triggers]: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
121+
[github-actions-docs]: https://docs.github.com/actions
122+
[understanding-actions]: https://docs.github.com/actions/about-github-actions/understanding-github-actions
123+
[workflow-syntax]: https://docs.github.com/actions/writing-workflows/workflow-syntax-for-github-actions
124+
[workflow-triggers]: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
124125
[walkthrough-previous]: 0-setup.md
125-
[walkthrough-next]: 2-running-tests.md
126+
[walkthrough-next]: 2-code-scanning.md
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Securing the Development Pipeline
2+
3+
| [← Introduction & Your First Workflow][walkthrough-previous] | [Next: Running Tests →][walkthrough-next] |
4+
|:-----------------------------------|------------------------------------------:|
5+
6+
In the previous exercise you created your first GitHub Actions workflow — a manually triggered "Hello World." Before building out CI/CD, let's explore security. Ensuring code security is imperative in today's environment, and GitHub provides tools that automate this for you — many of which are powered by GitHub Actions under the hood.
7+
8+
When we think about how we create code today, there are three main areas to secure:
9+
10+
- The **code we write** — which may contain vulnerabilities
11+
- The **libraries we use** — which may have known security issues
12+
- The **credentials we manage** — which may accidentally leak into source code
13+
14+
[GitHub Advanced Security][advanced-security] provides a suite of tools covering each of these areas. Let's explore and enable them on our repository.
15+
16+
## Scenario
17+
18+
Security is important in every application. By detecting potential vulnerabilities early, teams can make updates before incidents occur. The shelter wants to ensure insecure code and libraries are detected as early as possible. You'll enable Dependabot, secret scanning, and code scanning to meet these needs.
19+
20+
## Background
21+
22+
[GitHub Advanced Security][advanced-security-docs] is a set of security features available directly in GitHub. The three pillars are:
23+
24+
- **Code scanning** analyzes your source code for security vulnerabilities using [CodeQL][about-code-scanning], GitHub's semantic code analysis engine. When enabled, it runs as a GitHub Actions workflow — the same automation platform you used in the previous exercise. Every push and pull request triggers the analysis automatically.
25+
- **Dependabot** monitors your project's dependencies for known vulnerabilities and can automatically create [pull requests][about-prs] to update insecure packages to safe versions.
26+
- **Secret scanning** detects tokens, keys, and other credentials that have been committed to your repository, and can block pushes that contain [supported secrets][supported-secrets].
27+
28+
> [!NOTE]
29+
> Code scanning is built on [GitHub Actions][github-actions]. When you enable CodeQL's default setup, GitHub creates and manages a workflow for you behind the scenes. You'll see this connection more clearly when you navigate to the **Actions** tab after enabling it. This is a great example of how Actions powers automation across the GitHub platform — not just CI/CD pipelines you write yourself.
30+
31+
## Configure Dependabot
32+
33+
Most projects depend on open source and external libraries. While modern development would be impossible without them, we always need to ensure the dependencies we use are secure. [Dependabot][dependabot-quickstart] monitors your repository's dependencies and raises alerts — or even creates pull requests — to update insecure packages.
34+
35+
Public repositories on GitHub automatically have Dependabot alerts enabled. Let's configure Dependabot to also create PRs that update insecure library versions automatically.
36+
37+
1. Navigate to your repository on GitHub.
38+
2. Select **Settings** > **Code security** (under **Security** in the sidebar).
39+
3. Locate the **Dependabot** section.
40+
41+
![Screenshot of the Dependabot section](../shared-images/dependabot-settings.png)
42+
43+
4. Select **Enable** next to **Dependabot security updates** to configure Dependabot to create PRs to resolve alerts.
44+
45+
You've now enabled Dependabot alerts and security updates! When an insecure library is detected, you'll receive an alert, and Dependabot will create a pull request to update to a secure version.
46+
47+
> [!TIP]
48+
> Dependabot doesn't just alert you — it can automatically create pull requests that bump library versions to secure ones. When you pair this with a CI pipeline that runs tests on every PR (which you'll build in the [next exercise][walkthrough-next]), those Dependabot PRs are automatically tested before merging. This creates a powerful feedback loop: vulnerabilities are detected, fixes are proposed, and your tests verify the update won't break anything — all without manual intervention.
49+
50+
> [!IMPORTANT]
51+
> After enabling Dependabot security updates you may notice new pull requests created for potentially outdated packages. For this workshop you can ignore these pull requests.
52+
53+
## Enable secret scanning
54+
55+
Many developers have accidentally checked in code containing tokens or credentials. Regardless of the reason, even seemingly innocuous tokens can create a security issue. [Secret scanning][about-secret-scanning] detects tokens in your source code and raises alerts. With push protection enabled, pushes containing supported secrets are blocked before they reach your repository.
56+
57+
1. On the same **Code security** settings page, locate the **Secret scanning** section.
58+
2. Next to **Receive alerts on GitHub for detected secrets, keys or other tokens**, select **Enable**.
59+
3. Next to **Push protection**, select **Enable** to block pushes containing a [supported secret][supported-secrets].
60+
61+
![Screenshot of fully configured secret scanning](../shared-images/secret-scanning-settings.png)
62+
63+
You've now enabled secret scanning and push protection — helping prevent credentials from reaching your repository.
64+
65+
## Enable code scanning
66+
67+
There is a direct relationship between the amount of code an organization writes and its potential attack surface. [Code scanning][about-code-scanning] analyzes your source code for known vulnerabilities. When an issue is detected on a pull request, a comment is added highlighting the affected line with contextual information for the developer.
68+
69+
Let's enable code scanning with the default CodeQL setup. This runs automatically whenever code is pushed to `main` or a pull request targets `main`, and on a regular schedule to catch newly discovered vulnerabilities.
70+
71+
1. On the same **Code security** settings page, locate the **Code scanning** section.
72+
2. Next to **CodeQL analysis**, select **Set up** > **Default**.
73+
74+
![Screenshot of code scanning dropdown menu](../shared-images/code-scanning-setup.png)
75+
76+
3. On the **CodeQL default configuration** dialog, select **Enable CodeQL**.
77+
78+
![Screenshot of code scanning dialog](../shared-images/code-scanning-dialog.png)
79+
80+
> [!IMPORTANT]
81+
> Your list of languages may be different from what's shown in the screenshot.
82+
83+
A background process starts and configures a CodeQL analysis workflow for your repository.
84+
85+
> [!TIP]
86+
> After enabling CodeQL, navigate to the **Actions** tab in your repository. You'll see a new **CodeQL** workflow listed alongside the **Hello World** workflow you created earlier. This is the Actions workflow that GitHub created automatically to run code scanning — proof that Actions isn't just for CI/CD, but powers many of GitHub's built-in features.
87+
88+
## Summary and next steps
89+
90+
You've enabled GitHub Advanced Security for your repository:
91+
92+
- **Dependabot** monitors dependencies for known vulnerabilities and creates PRs to update them.
93+
- **Secret scanning** detects leaked credentials and blocks pushes containing supported secrets.
94+
- **Code scanning** analyzes your source code using CodeQL, running as a GitHub Actions workflow on every push and PR.
95+
96+
These tools run automatically in the background, catching security issues before they reach production. Now that you've seen how GitHub uses Actions internally for security automation, it's time to build your own CI workflow. Next, we'll [automate testing][walkthrough-next] for the shelter's application.
97+
98+
### Resources
99+
100+
- [About GitHub Advanced Security][advanced-security-docs]
101+
- [About code scanning with CodeQL][about-code-scanning]
102+
- [Dependabot quickstart guide][dependabot-quickstart]
103+
- [About secret scanning][about-secret-scanning]
104+
- [GitHub Skills: Secure your repository's supply chain][skills-supply-chain]
105+
- [GitHub Skills: Secure code game][skills-secure-code]
106+
107+
| [← Introduction & Your First Workflow][walkthrough-previous] | [Next: Running Tests →][walkthrough-next] |
108+
|:-----------------------------------|------------------------------------------:|
109+
110+
[about-code-scanning]: https://docs.github.com/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning
111+
[about-prs]: https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
112+
[about-secret-scanning]: https://docs.github.com/code-security/secret-scanning/introduction/about-secret-scanning
113+
[advanced-security]: https://github.com/features/security
114+
[advanced-security-docs]: https://docs.github.com/get-started/learning-about-github/about-github-advanced-security
115+
[dependabot-quickstart]: https://docs.github.com/code-security/getting-started/dependabot-quickstart-guide
116+
[github-actions]: https://github.com/features/actions
117+
[supported-secrets]: https://docs.github.com/code-security/secret-scanning/introduction/supported-secret-scanning-patterns
118+
[skills-supply-chain]: https://github.com/skills/secure-repository-supply-chain
119+
[skills-secure-code]: https://github.com/skills/secure-code-game
120+
[walkthrough-previous]: 1-introduction.md
121+
[walkthrough-next]: 3-running-tests.md

0 commit comments

Comments
 (0)