Skip to content

Commit c1e5033

Browse files
committed
Welcome to Introduction to GitHub
0 parents  commit c1e5033

10 files changed

+908
-0
lines changed

.github/script/STEP

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

.github/script/update-for-step.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Check that we are on FROM_STEP"
4+
if [ "$(cat .github/script/STEP)" != $FROM_STEP ]
5+
then
6+
echo "Current step is not $FROM_STEP"
7+
exit 0
8+
fi
9+
10+
echo "Make sure we are on the main branch"
11+
git checkout main
12+
13+
echo "Remove 'open' from any <details> tags"
14+
sed -r 's/<details id=([0-9]+) open>/<details id=\1>/g' README.md > tmp
15+
mv tmp README.md
16+
17+
echo "Add 'open' to step TO_STEP"
18+
sed -r "s/<details id=$TO_STEP>/<details id=$TO_STEP open>/g" README.md > tmp
19+
mv tmp README.md
20+
21+
echo "Update the STEP file to TO_STEP"
22+
echo "$TO_STEP" > .github/script/STEP
23+
24+
echo "Commit the files, and push to main"
25+
git config user.name github-actions
26+
git config user.email [email protected]
27+
git add README.md
28+
git add .github/script/STEP
29+
git commit -m "Update to $TO_STEP in STEP and README.md"
30+
git push
31+
32+
echo "If BRANCH_NAME, update that branch as well"
33+
if git show-ref --quiet refs/heads/$BRANCH_NAME
34+
then
35+
git checkout $BRANCH_NAME
36+
git cherry-pick main
37+
git push
38+
else
39+
echo "Branch $BRANCH_NAME does not exist"
40+
fi

.github/workflows/0-start.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
jobs:
16+
update_to_step_1:
17+
name: On start
18+
19+
# We will only run this action when:
20+
# 1. This repository isn't the template repository
21+
# 2. The STEP is currently '0' (see lower `if`s)
22+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
23+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
24+
if: ${{ github.repository_owner != 'githublearn' }}
25+
26+
# We'll run Ubuntu for performance instead of Mac or Windows
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
# We'll need to check out the repository so that we can edit the README
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0 # Let's get all the branches
35+
36+
# Update README to close <details id=0>
37+
# and open <details id=1>
38+
# and set STEP to '1'
39+
- name: Update to step 1
40+
run: ./.github/script/update-for-step.sh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
GITHUB_REPOSITORY: ${{ github.repository }}
44+
FROM_STEP: 0
45+
TO_STEP: 1
46+
BRANCH_NAME: my-first-branch
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Step 1, Create a branch
2+
3+
# This step listens for the learner to create branch `my-first-branch`
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 create a branch or tag
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
create:
12+
13+
jobs:
14+
update_to_step_2:
15+
name: On create a branch
16+
17+
# We will only run this action when:
18+
# 1. This repository isn't the template repository
19+
# 2. The STEP is currently '1' (see lower `if`s)
20+
# 3. The event is a branch
21+
# 4. The branch name is `my-first-branch`
22+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
23+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
24+
if: ${{ github.repository_owner != 'githublearn' && github.ref_type == 'branch' && github.ref_name == 'my-first-branch' }}
25+
26+
# We'll run Ubuntu for performance instead of Mac or Windows
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
# We'll need to check out the repository so that we can edit the README
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0 # Let's get all the branches
35+
36+
# Update README to close <details id=1>
37+
# and open <details id=2>
38+
# and set STEP to '2'
39+
- name: Update to step 2
40+
run: ./.github/script/update-for-step.sh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
FROM_STEP: 1
44+
TO_STEP: 2
45+
BRANCH_NAME: my-first-branch

.github/workflows/2-commit-a-file.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Step 2, Commit a file
2+
3+
# This step listens for the learner to commit a file to branch `my-first-branch`
4+
# This step sets `STEP` to 3
5+
# This step closes <details id=2> and opens <details id=3>
6+
7+
# This action will run every time there's a push to `my-first-branch`
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+
- my-first-branch
14+
15+
jobs:
16+
update_to_step_3:
17+
name: On commit a file
18+
19+
# We will only run this action when:
20+
# 1. This repository isn't the template repository
21+
# 2. The STEP is currently '2' (see lower `if`s)
22+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
23+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
24+
if: ${{ github.repository_owner != 'githublearn' }}
25+
26+
# We'll run Ubuntu for performance instead of Mac or Windows
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
# We'll need to check out the repository so that we can edit the README
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0 # Let's get all the branches
35+
36+
# Update README to close <details id=2>
37+
# and open <details id=3>
38+
# and set STEP to '3'
39+
- name: Update to step 3
40+
run: ./.github/script/update-for-step.sh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
FROM_STEP: 2
44+
TO_STEP: 3
45+
BRANCH_NAME: my-first-branch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Step 3, Open a pull request
2+
3+
# This step listens for the learner to open a pull request with branch `my-first-branch`
4+
# This step sets `STEP` to 4
5+
# This step closes <details id=3> and opens <details id=4>
6+
7+
# This will run every time we create a branch or tag
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
pull_request:
12+
types:
13+
- opened
14+
- reopened
15+
16+
jobs:
17+
update_to_step_4:
18+
name: On open a pull request
19+
20+
# We will only run this action when:
21+
# 1. This repository isn't the template repository
22+
# 2. The STEP is currently '3' (see lower `if`s)
23+
# 3. The head branch name is `my-first-branch`
24+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
25+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
26+
if: ${{ github.repository_owner != 'githublearn' && github.head_ref == 'my-first-branch' }}
27+
28+
# We'll run Ubuntu for performance instead of Mac or Windows
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
# We'll need to check out the repository so that we can edit the README
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
with:
36+
fetch-depth: 0 # Let's get all the branches
37+
ref: my-first-branch # Important, as normally `pull_request` event won't grab other branches
38+
39+
# Update README to close <details id=3>
40+
# and open <details id=4>
41+
# and set STEP to '4'
42+
- name: Update to step 4
43+
run: ./.github/script/update-for-step.sh
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
FROM_STEP: 3
47+
TO_STEP: 4
48+
BRANCH_NAME: my-first-branch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Step 4, Merge your pull request
2+
3+
# This step listens for the learner to merge a pull request with branch `my-first-branch`
4+
# This step sets `STEP` to x
5+
# This step closes <details id=4> and opens <details id=x>
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+
workflow_dispatch:
11+
push:
12+
branches:
13+
- main
14+
15+
jobs:
16+
update_to_step_x:
17+
name: On merge your pull request
18+
19+
# We will only run this action when:
20+
# 1. This repository isn't the template repository
21+
# 2. The STEP is currently '4' (see lower `if`s)
22+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
23+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
24+
if: ${{ github.repository_owner != 'githublearn' }}
25+
26+
# We'll run Ubuntu for performance instead of Mac or Windows
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
# We'll need to check out the repository so that we can edit the README
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
fetch-depth: 0 # Let's get all the branches
35+
36+
# Update README to close <details id=4>
37+
# and open <details id=X>
38+
# and set STEP to X
39+
- name: Update to step X
40+
run: ./.github/script/update-for-step.sh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
FROM_STEP: 4
44+
TO_STEP: X
45+
BRANCH_NAME: my-first-branch

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

0 commit comments

Comments
 (0)