Skip to content

Commit a5ec8ab

Browse files
committed
Codespces Skills
0 parents  commit a5ec8ab

12 files changed

+1108
-0
lines changed

Diff for: .github/script/STEP

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

Diff for: .github/script/check-file.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Make sure this file is executable
3+
chmod a+x .github/script/check-file.sh
4+
5+
# Make sure to escape your backslashes => \\ <= in YAML
6+
# So that its still a single \ in bash
7+
8+
echo "Check that $FILE includes $SEARCH"
9+
if grep --extended-regexp "$SEARCH" -- $FILE
10+
then
11+
echo "Found $SEARCH in $FILE"
12+
else
13+
echo "Missing $SEARCH in $FILE"
14+
echo "----------------"
15+
echo "$(cat $FILE)"
16+
exit 204 # We're sending a weird code so it looks different from other "failures"
17+
fi

Diff for: .github/workflows/0-start.yml

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

Diff for: .github/workflows/1-first-codespace.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Step 1, 1-Create codespace and push code
2+
3+
# This step triggers after TBD-step-1-event-desc
4+
# This step sets STEP to 2
5+
# This step closes <details id=1> and opens <details id=2>
6+
7+
# This will run every time we TBD-step-1-event-desc
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
16+
permissions:
17+
# Need `contents: read` to checkout the repository
18+
# Need `contents: write` to update the step metadata
19+
contents: write
20+
21+
jobs:
22+
# The purpose of this job is to output the current step number
23+
# (retreived from the STEP file). This output variable can
24+
# then be referenced in other jobs and used in conditional
25+
# expressions.
26+
get_current_step:
27+
name: Check current step number
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
- id: get_step
33+
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)"
34+
outputs:
35+
current_step: ${{ steps.get_step.outputs.current_step }}
36+
37+
on_add_dependency:
38+
name: On Add dependency
39+
needs: get_current_step
40+
41+
# We will only run this action when:
42+
# 1. This repository isn't the template repository
43+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
44+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
45+
if: ${{ !github.event.repository.is_template && needs.get_current_step.outputs.current_step == 1 }}
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@v2
54+
55+
# Verify the learner added the file contents
56+
- name: Check workflow contents, jobs
57+
run: |
58+
chmod a+x .github/script/check-file.sh
59+
./.github/script/check-file.sh
60+
env:
61+
FILE: "index.html"
62+
SEARCH: "Hello from the codespace"
63+
64+
# Update README to close <details id=1> and open <details id=2>
65+
# and set STEP to '2'
66+
- name: Update to step 2
67+
uses: skills/action-update-step@v1
68+
with:
69+
token: ${{ secrets.GITHUB_TOKEN }}
70+
from_step: 1
71+
to_step: 2

Diff for: .github/workflows/2-custom-image.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Step 2, 2-custom image check
2+
3+
# This step triggers after First Codespace
4+
# This step sets STEP to 3
5+
# This step closes <details id=2> and opens <details id=3>
6+
7+
# This will run every time we TBD-step-2-event-desc
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
16+
permissions:
17+
# Need `contents: read` to checkout the repository
18+
# Need `contents: write` to update the step metadata
19+
contents: write
20+
21+
jobs:
22+
# The purpose of this job is to output the current step number
23+
# (retreived from the STEP file). This output variable can
24+
# then be referenced in other jobs and used in conditional
25+
# expressions.
26+
get_current_step:
27+
name: Check current step number
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
- id: get_step
33+
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)"
34+
outputs:
35+
current_step: ${{ steps.get_step.outputs.current_step }}
36+
37+
on_DependabotPrCreated:
38+
name: On Creation of a PR
39+
needs: get_current_step
40+
41+
# We will only run this action when:
42+
# 1. This repository isn't the template repository
43+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
44+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
45+
if: ${{ !github.event.repository.is_template && needs.get_current_step.outputs.current_step == 2 }}
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@v2
54+
with:
55+
fetch-depth: 0 # Let's get all the branches
56+
57+
# Verify the devcontainer.json has an image
58+
- name: Check package.json
59+
run: |
60+
chmod a+x .github/script/check-file.sh
61+
./.github/script/check-file.sh
62+
env:
63+
FILE: ".devcontainer/devcontainer.json"
64+
SEARCH: "mcr.microsoft.com/vscode/devcontainers/universal:latest"
65+
66+
67+
# Update README to close <details id=2> and open <details id=3>
68+
# and set STEP to '3'
69+
- name: Update to step 3
70+
uses: skills/action-update-step@v1
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
from_step: 2
74+
to_step: 3

Diff for: .github/workflows/3-customize-codespace.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Step 3, 3-Customize Codespace
2+
3+
# This step triggers after TBD-step-3-event-desc
4+
# This step sets STEP to 4
5+
# This step closes <details id=3> and opens <details id=X>
6+
7+
# This will run every time
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
16+
permissions:
17+
# Need `contents: read` to checkout the repository
18+
# Need `contents: write` to update the step metadata
19+
contents: write
20+
21+
jobs:
22+
# The purpose of this job is to output the current step number
23+
# (retreived from the STEP file). This output variable can
24+
# then be referenced in other jobs and used in conditional
25+
# expressions.
26+
get_current_step:
27+
name: Check current step number
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v2
32+
- id: get_step
33+
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)"
34+
outputs:
35+
current_step: ${{ steps.get_step.outputs.current_step }}
36+
37+
on_DependabotSecurityUpdates:
38+
name: On Dependabot Security Updates
39+
needs: get_current_step
40+
41+
# We will only run this action when:
42+
# 1. This repository isn't the template repository
43+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
44+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
45+
if: ${{ !github.event.repository.is_template && needs.get_current_step.outputs.current_step == 3 }}
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@v2
54+
with:
55+
fetch-depth: 0 # Let's get all the branches
56+
57+
# Verify the postCreateCommand was added
58+
- name: Check for postCreateCommand
59+
run: |
60+
chmod a+x .github/script/check-file.sh
61+
./.github/script/check-file.sh
62+
env:
63+
FILE: ".devcontainer/devcontainer.json"
64+
SEARCH: "postCreateCommand"
65+
66+
67+
# Update README to close <details id=3> and open <details id=4>
68+
# and set STEP to '4'
69+
- name: Update to step 4
70+
uses: skills/action-update-step@v1
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
from_step: 3
74+
to_step: 4

Diff for: .github/workflows/4-personalize-codespace.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Step 4, 4-Personalize your Codespace
2+
# This step triggers after TBD-step-4-event-desc
3+
# This step sets STEP to X
4+
# This step closes <details id=3> and opens <details X>
5+
6+
# This will run every time we TBD-step-4-event-desc
7+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- '.github/dependabot.yml'
15+
16+
# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
17+
permissions:
18+
# Need `contents: read` to checkout the repository
19+
# Need `contents: write` to update the step metadata
20+
contents: write
21+
22+
jobs:
23+
# The purpose of this job is to output the current step number
24+
# (retreived from the STEP file). This output variable can
25+
# then be referenced in other jobs and used in conditional
26+
# expressions.
27+
get_current_step:
28+
name: Check current step number
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
- id: get_step
34+
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)"
35+
outputs:
36+
current_step: ${{ steps.get_step.outputs.current_step }}
37+
38+
on_TBD-step-4-event:
39+
name: On TBD-step-4-event
40+
needs: get_current_step
41+
42+
# We will only run this action when:
43+
# 1. This repository isn't the template repository
44+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
45+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
46+
if: ${{ !github.event.repository.is_template && needs.get_current_step.outputs.current_step == 4}}
47+
48+
# We'll run Ubuntu for performance instead of Mac or Windows
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
# We'll need to check out the repository so that we can edit the README
53+
- name: Checkout
54+
uses: actions/checkout@v2
55+
with:
56+
fetch-depth: 0 # Let's get all the branches
57+
58+
# Verify the setup.sh added the file contents
59+
- name: Check workflow contents, jobs
60+
run: |
61+
chmod a+x .github/script/check-file.sh
62+
./.github/script/check-file.sh
63+
env:
64+
FILE: "dotfiles/setup.sh"
65+
SEARCH: "Codespace"
66+
67+
# Update README to close <details id=3> and open <details id=X>
68+
# and set STEP to 'X'
69+
- name: Update to step X
70+
uses: skills/action-update-step@v1
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
from_step: 4
74+
to_step: X

0 commit comments

Comments
 (0)