Skip to content

Commit 26c6fdc

Browse files
authoredFeb 20, 2025··
Initial commit
0 parents  commit 26c6fdc

18 files changed

+791
-0
lines changed
 

‎.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
8+
- package-ecosystem: "devcontainers"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"

‎.github/steps/-step.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

‎.github/steps/0-welcome.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- readme -->

‎.github/steps/1-first-codespace.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!--
2+
<<< Author notes: Step 1 >>>
3+
Choose 3-5 steps for your course.
4+
The first step is always the hardest, so pick something easy!
5+
Link to docs.github.com for further explanations.
6+
Encourage users to open new tabs for steps!
7+
-->
8+
9+
## Step 1: Create your first codespace and push code
10+
11+
_Welcome to "Develop code using GitHub Codespaces and Visual Studio Code"! :wave:_
12+
13+
**What's the big deal about using a codespace for software development?** A codespace is a development environment that's hosted in the cloud. You can customize your project for GitHub Codespaces by committing configuration files to your repository (also known as configuration-as-code), which creates a repeatable codespace configuration for all users of your project. Each codespace you create is hosted by GitHub in a Docker container that runs on a virtual machine. You can choose the type of machine you want to use depending on the resources you need.
14+
15+
GitHub offers a range of features to help your development team customize a codespace to reach peak configuration and performance needs. For example, you can:
16+
17+
- Create a codespace from your repository.
18+
- Push code from the codespace to your repository.
19+
- Use VS Code to develop code.
20+
- Customize the codespace with custom images.
21+
- Manage the codespace.
22+
23+
To begin developing using GitHub Codespaces, you can create a codespace from a template or from any branch or commit in a repository. When you create a codespace from a template, you can start from a blank template or choose a template suitable for the work you're doing.
24+
25+
### :keyboard: Activity: Start a codespace
26+
27+
**We recommend opening another browser tab to work through the following activities so you can keep these instructions open for reference.**
28+
29+
1. Start from the landing page of your repository.
30+
1. Click the green **Code** button located in the middle of the page.
31+
1. Select the **Codespaces** tab in the box that pops up and then click the **Create codespace on main** button.
32+
33+
> Wait about 2 minutes for the codespace to spin itself up.
34+
> **Note**: It's a virtual machine spinning up in the background.
35+
36+
1. Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below:
37+
![codespace1](https://user-images.githubusercontent.com/26442605/207355196-71aab43f-35a9-495b-bcfe-bf3773c2f1b3.png)
38+
39+
### :keyboard: Activity: Push code to your repository from the codespace
40+
41+
1. From inside the codespace in the VS Code explorer window, select the `index.html` file.
42+
1. Replace the **h1** header with the below:
43+
44+
```html
45+
<h1>Hello from the codespace!</h1>
46+
```
47+
48+
1. Save the file.
49+
> **Note**: The file should autosave.
50+
1. Use the VS Code terminal to commit the file change by entering the following commit message:
51+
52+
```shell
53+
git commit -a -m "Adding hello from the codespace!"
54+
```
55+
56+
1. Push the changes back to your repository. From the VS Code terminal, enter:
57+
58+
```shell
59+
git push
60+
```
61+
62+
1. Your code has been pushed to your repository!
63+
1. Switch back to the homepage of your repository and view the `index.html` to verify the new code was pushed to your repository.
64+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

‎.github/steps/2-custom-image.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!--
2+
<<< Author notes: Step 2 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 2: Add a custom image to your codespace!
8+
9+
_Nice work! :tada: You created your first codespace and pushed code using VS Code!_
10+
11+
You can configure the development container for a repository so that any codespace created for that repository will give you a tailored development environment, complete with all the tools and runtimes you need to work on a specific project.
12+
13+
**What are development containers?** Development containers, or dev containers, are Docker containers that are specifically configured to provide a fully featured development environment. Whenever you work in a codespace, you are using a dev container on a virtual machine.
14+
15+
A dev container file is a JSON file that lets you customize the default image that runs your codespace, VS code settings, run custom code, forward ports and much more!
16+
17+
Let's add a `devcontainer.json` file and add a custom image.
18+
19+
### :keyboard: Activity: Add a .devcontainer.json file to customize your codespace
20+
21+
1. Navigating back to your **Code** tab of your repository, click the **Add file** drop-down button, and then click `Create new file`.
22+
1. Type or paste the following in the empty text field prompt to name your file.
23+
24+
```
25+
.devcontainer/devcontainer.json
26+
```
27+
28+
1. In the body of the new **.devcontainer/devcontainer.json** file, add the following content:
29+
30+
```jsonc
31+
{
32+
// Name this configuration
33+
"name": "Codespace for Skills!",
34+
// Use the base codespace image
35+
"image": "mcr.microsoft.com/vscode/devcontainers/universal:latest",
36+
37+
"remoteUser": "codespace",
38+
"overrideCommand": false
39+
}
40+
```
41+
42+
1. Click **Commit changes** and then select **Commit changes directly to the `main` branch**.
43+
1. Create a new codespace by navigating back to the **Code** tab of your repository.
44+
1. Click the green **Code** button located in the middle of the page.
45+
1. Click the **Codespaces** tab on the box that pops up.
46+
1. Click the **Create codespace on main** button OR click the `+` sign on the tab. This will create a new codespace on the main branch. (Notice your other codespace listed here.)
47+
48+
> Wait about **2 minutes** for the codespace to spin itself up.
49+
50+
1. Verify that your new codespace is running, as you did previously.
51+
52+
Note the image being used is the default image provided for GitHub Codespaces. It includes runtimes and tools for Python, Node.js, Docker, and more. See the full list here: https://aka.ms/ghcs-default-image. Your development team can use any custom image that has the necessary prerequisites installed. For more information, see [codespace image](https://aka.ms/configure-codespace).
53+
54+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!--
2+
<<< Author notes: Step 3 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 3: Customize your codespace!
8+
9+
_Nice work! :tada: You created a codespace with a custom image!_
10+
11+
You can customize your codespace by adding VS code extensions, adding features, setting host requirements, and much more.
12+
13+
Let's customize some settings in the `devcontainer.json` file!
14+
15+
### :keyboard: Activity: Add customizations to the `devcontainer` file
16+
17+
1. Navigate to the `.devcontainer/devcontainer.json` file.
18+
1. Add the following customizations to the body of the file before the last `}`.
19+
20+
```jsonc
21+
,
22+
// Add the IDs of extensions you want installed when the container is created.
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"GitHub.copilot"
27+
]
28+
},
29+
"codespaces": {
30+
"openFiles": [
31+
"codespace.md"
32+
]
33+
}
34+
}
35+
```
36+
37+
1. Click **Commit changes** and then select **Commit changes directly to the `main` branch**.
38+
1. Create a new codespace by navigating to the landing page of your repository.
39+
1. Click the **Code** button located in the middle of the page.
40+
1. Click the **Codespaces** tab on the box that pops up.
41+
1. Ensure the number of active codespaces does not reach the maximum (typically 2). For more information, see [understanding the codespace lifecycle](https://docs.github.com/en/codespaces/getting-started/understanding-the-codespace-lifecycle).
42+
43+
> **Tip**: To stop an active codespace, click the **•••** next to **<span>&#x25cf;</span>Active** and select **Stop codespace** from the menu.
44+
45+
1. Click the **Create codespace on main** button.
46+
47+
> Wait about **2 minutes** for the codespace to spin itself up.
48+
49+
1. Verify your codespace is running, as you did previously.
50+
1. The `codespace.md` file should show up in the VS Code editor.
51+
1. The `copilot` extension should show up in the VS Code extension list.
52+
53+
This will add a VS Code extension as well as open a file on start up of the codespace.
54+
55+
Next lets add some code to run upon creation of the codespace!
56+
57+
### :keyboard: Activity: Execute code upon creation of the codespace
58+
59+
1. Edit the `.devcontainer/devcontainer.json` file.
60+
1. Add the following postCreateCommand to the body of the file before the last `}`.
61+
62+
```jsonc
63+
,
64+
"postCreateCommand": "echo '# Writing code upon codespace creation!' >> codespace.md"
65+
```
66+
67+
1. Click **Commit changes** and then select **Commit changes directly to the `main` branch**.
68+
1. Create a new codespace by navigating to the landing page of your repository.
69+
1. Click the **Code** button located in the middle of the page.
70+
1. Click the **Codespaces** tab on the box that pops up.
71+
1. Click the **Create codespace on main** button.
72+
73+
> Wait about **2 minutes** for the codespace to spin itself up.
74+
75+
1. Verify your codespace is running, as you did previously.
76+
1. Verify the `codespace.md` file now has the text `Writing code upon codespace creation!`.
77+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!--
2+
<<< Author notes: Step 4 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 4: Personalize your codespace!
8+
9+
_Nicely done customizing your codespace!_ :partying_face:
10+
11+
When using any development environment, customizing the settings and tools to your preferences and workflows is an important step. GitHub Codespaces offers two main ways of personalizing your codespace: `Settings Sync` with VS Code and `dotfiles`.
12+
13+
`Dotfiles` will be the focus of this activity.
14+
15+
**What are `dotfiles`?** Dotfiles are files and folders on Unix-like systems starting with . that control the configuration of applications and shells on your system. You can store and manage your dotfiles in a repository on GitHub.
16+
17+
Let's see how this works!
18+
19+
### :keyboard: Activity: Enable a `dotfile` for your codespace
20+
21+
1. Start from the landing page of your repository.
22+
1. In the upper-right corner of any page, click your profile photo, and then click **Settings**.
23+
1. In the **Code, planning, and automation** section of the sidebar, click **Codespaces**.
24+
1. Under **Dotfiles**, select **Automatically install dotfiles** so that GitHub Codespaces automatically installs your dotfiles into every new codespace you create.
25+
1. Click **Select repository** and then choose your current skills working repository as the repository from which to install dotfiles.
26+
27+
### :keyboard: Activity: Add a `dotfile` to your repository and run your codespace
28+
29+
1. Start from the landing page of your repository.
30+
1. Click the **Code** button located in the middle of the page.
31+
1. Click the **Codespaces** tab on the box that pops up.
32+
1. Click the **Create codespace on main** button.
33+
34+
> Wait about **2 minutes** for the codespace to spin itself up.
35+
36+
1. Verify your codespace is running. The browser should contain a VS Code web-based editor and a terminal should be present such as the below:
37+
38+
![codespace1](https://user-images.githubusercontent.com/26442605/207355196-71aab43f-35a9-495b-bcfe-bf3773c2f1b3.png)
39+
40+
1. From inside the codespace in the VS Code explorer window, create a new file `setup.sh`.
41+
1. Enter the following code into the file:
42+
43+
```bash
44+
#!/bin/bash
45+
46+
sudo apt-get update
47+
sudo apt-get install sl
48+
echo "export PATH=\$PATH:/usr/games" >> ~/.bashrc
49+
```
50+
51+
1. Save the file.
52+
> **Note**: The file should autosave.
53+
1. Commit the file changes. From the VS Code terminal enter:
54+
55+
```shell
56+
git add setup.sh --chmod=+x
57+
git commit -m "Adding setup.sh from the codespace!"
58+
```
59+
60+
1. Push the changes back to your repository. From the VS Code terminal, enter:
61+
62+
```shell
63+
git push
64+
```
65+
66+
1. Switch back to the homepage of your repository and view the `setup.sh` to verify the new code was pushed to your repository.
67+
1. Close the codespace web browser tab.
68+
1. Click the **Create codespace on main** button.
69+
70+
> Wait about **2 minutes** for the codespace to spin itself up.
71+
72+
1. Verify your codespace is running, as you did previously.
73+
1. Verify the `setup.sh` file is present in your VS Code editor.
74+
1. From the VS Code terminal, type or paste:
75+
76+
```shell
77+
sl
78+
```
79+
80+
1. Enjoy the show!
81+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

‎.github/steps/X-finish.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--
2+
<<< Author notes: Finish >>>
3+
Review what we learned, ask for feedback, provide next steps.
4+
-->
5+
6+
## Finish
7+
8+
_Congratulations friend, you've completed this course!_
9+
10+
<img src="https://octodex.github.com/images/welcometocat.png" alt=celebrate width=300 align=right>
11+
12+
Here's a recap of all the tasks you've accomplished in your repository:
13+
14+
- You learned how to create a codespace and push code to your repository from the codespace.
15+
- You learned how to use custom images in your codespace.
16+
- You learned how to customize your codespace.
17+
- You learned how to personalize your codespace.
18+
19+
### Additional learning and resources
20+
21+
- [Developing in a codespace](https://docs.github.com/en/codespaces/developing-in-codespaces/developing-in-a-codespace). Learn how to delete a codespace, open an existing codespace, connect to a private network, forward ports, and much more.
22+
- [Set up your repository](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers). Learn how to set minimum machine specs for a codespace, add badges, set up a template repo, and much more.
23+
- [Personalize and customize GitHub Codespaces](https://docs.github.com/en/codespaces/customizing-your-codespace/personalizing-github-codespaces-for-your-account). Learn how to use setting sync for your codespace, add dotfiles, set the default region, set the default editor, and much more.
24+
- [Prebuild your codespace](https://docs.github.com/en/codespaces/prebuilding-your-codespaces/about-github-codespaces-prebuilds)
25+
- [Manage your codespace](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/enabling-github-codespaces-for-your-organization)
26+
27+
### What's next?
28+
29+
- Learn more about securing your supply chain by reading: [GitHub Codespaces overview](https://docs.github.com/en/codespaces/overview).
30+
- [We'd love to hear what you thought of this course](https://github.com/orgs/skills/discussions/categories/code-with-codespaces).
31+
- [Learn another GitHub skill](https://github.com/skills).
32+
- [Read the Get started with GitHub docs](https://docs.github.com/en/get-started).
33+
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore).

‎.github/workflows/0-welcome.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Step 0, Welcome
2+
3+
# This step triggers after the learner creates a new repository from the template.
4+
# This workflow updates from step 0 to step 1.
5+
6+
# This will run every time we create push a commit to `main`.
7+
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
8+
on:
9+
push:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
15+
permissions:
16+
# Need `contents: read` to checkout the repository.
17+
# Need `contents: write` to update the step metadata.
18+
contents: write
19+
20+
jobs:
21+
# Get the current step to only run the main job when the learner is on the same step.
22+
get_current_step:
23+
name: Check current step number
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- id: get_step
29+
run: |
30+
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
31+
outputs:
32+
current_step: ${{ steps.get_step.outputs.current_step }}
33+
34+
on_start:
35+
name: On start
36+
needs: get_current_step
37+
38+
# We will only run this action when:
39+
# 1. This repository isn't the template repository.
40+
# 2. The step is currently 0.
41+
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
42+
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
43+
if: >-
44+
${{ !github.event.repository.is_template
45+
&& needs.get_current_step.outputs.current_step == 0}}
46+
47+
# We'll run Ubuntu for performance instead of Mac or Windows.
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
# We'll need to check out the repository so that we can edit the README.
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 0 # Let's get all the branches.
56+
57+
# In README.md, switch step 0 for step 1.
58+
- name: Update to step 1
59+
uses: skills/action-update-step@v2
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
from_step: 0
63+
to_step: 1

0 commit comments

Comments
 (0)