-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.md Update README.md Update README.md Update README.md Create git-tips.md Update git-tips.md Update README.md Update 0-start.yml Update STEP Create check-file.sh Create create-workflow-pr.sh Create initialize-repository.sh Update 0-start.yml Update 0-start.yml Create index.html added docs files Update and rename 1-tbd.yml to 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update STEP Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update 1-resolve-duplicate-issues.yml Update STEP Update 1-resolve-duplicate-issues.yml Update STEP Update to 2 in STEP and README.md Update README.md Update _sidebar.md Update _sidebar.md Update and rename 2-tbd.yml to 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update 2-find-commit-in-history.yml Update to 3 in STEP and README.md Update 1-resolve-duplicate-issues.yml add sidebar to documentation add sidebar to documentation Update 2-find-commit-in-history.yml Update README.md Update and rename 3-tbd.yml to 3-fix-broken-sidebar.yml Delete 4-tbd.yml Delete 5-merge-your-pull-request.yml Fixing sidebar Fixing #2 Update 3-fix-broken-sidebar.yml Fixing sidebar Fixing #2 Fixing sidebar Fixing #2 Update 3-fix-broken-sidebar.yml Update to 4 in STEP and README.md Update README.md Update STEP Update to 4 in STEP and README.md Update 0-start.yml Update _sidebar.md Update README.md Update STEP git commit --amend#
- Loading branch information
0 parents
commit ff885ef
Showing
20 changed files
with
1,326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
# Make sure this file is executable | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
# chmod a+x .github/script/check-file.sh | ||
|
||
# Make sure to escape your backslashes => \\ <= in YAML | ||
# So that its still a single \ in bash | ||
|
||
# Check if pattern match found in file | ||
grep_pattern() { | ||
echo | ||
echo "Check that $1 includes $2" | ||
if grep --extended-regexp "$2" -- $1 | ||
then | ||
echo "Found $2 in $1" | ||
else | ||
echo "Missing $2 in $1" | ||
echo "----------------" | ||
echo "$(cat $1)" | ||
exit 204 # We're sending a weird code so it looks different from other "failures" | ||
fi | ||
} | ||
|
||
# Run grep check for each term in list | ||
search_list() { | ||
for pattern in "$@" | ||
do | ||
grep_pattern $FILE $pattern | ||
done | ||
} | ||
|
||
# Handle single search term | ||
if [ -n "${SEARCH+set}" ] && [ -n "${FILE+set}" ]; then | ||
grep_pattern $FILE $SEARCH | ||
|
||
# Handle multiple search terms, space delimited | ||
elif [ -n "${SEARCH_LIST+set}" ] && [ -n "${FILE+set}" ]; then | ||
search_list $SEARCH_LIST | ||
|
||
# Missing FILE or search term(s) | ||
else | ||
echo "FILE and (SEARCH | SEARCH_LIST) required" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
# Make sure this file is executable | ||
# chmod a+x .github/script/create-workflow-pr.sh | ||
|
||
git config user.name github-actions | ||
git config user.email [email protected] | ||
|
||
# If --pull-first is set, pull latest from main | ||
# before creating pull request | ||
if [ "$1" = "--pull-first" ] | ||
then | ||
echo "Merging main into $PR_BRANCH" | ||
git checkout $PR_BRANCH | ||
git pull origin main --no-rebase -X theirs --no-edit | ||
git push origin $PR_BRANCH | ||
fi | ||
|
||
echo "Create pull request for $PR_BRANCH into main" | ||
gh pr create --base main --head $PR_BRANCH --title "$PR_TITLE" --body "" | ||
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
# Make sure this file is executable | ||
# chmod a+x .github/script/initialize-repository.sh | ||
|
||
# USAGE: This should only be run once upon initial creation of the | ||
# learner's repository from the template repository. | ||
# Does a dry run by default, --dry-run=false to run live. | ||
|
||
# PURPOSE: This script establishes an initial related history for | ||
# all branches. It merges main into all other branches in this repository | ||
# while auto-resolving conflicts in favor of main. | ||
|
||
# BACKGROUND: This operation is required because when a repository is | ||
# created from a template repository with 'Include all branches', each | ||
# of the branches starts with only one initial commit and no related history. | ||
# | ||
# That state makes it impossible to create pull requests from the | ||
# step-specific branches into main as the learner progresses | ||
# through the course. | ||
|
||
# Setup committer identity | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
|
||
# Fetch all remote branches | ||
git pull --all | ||
|
||
# Create list of all remote branches | ||
branches=$(git branch -r | grep -v main | sed -r 's/origin\///g' | paste -s -d ' ' -) | ||
|
||
# Merge main into each branch | ||
echo -e "Merge main into each branch\n---" | ||
for branch in $branches | ||
do | ||
# Dry run by default | ||
if [[ $1 = '--dry-run=false' ]] | ||
then | ||
git checkout "$branch" | ||
git pull origin main --no-rebase -X theirs --allow-unrelated-histories --no-edit | ||
git push origin "$branch" | ||
echo "---" | ||
else | ||
echo "plan: merge main into $branch" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
# Make sure this file is executable | ||
# chmod a+x .github/script/update-step.sh | ||
|
||
echo "Check that we are on FROM_STEP" | ||
if [ "$(cat .github/script/STEP)" != $FROM_STEP ] | ||
then | ||
echo "Current step is not $FROM_STEP" | ||
exit 0 | ||
fi | ||
|
||
echo "Make sure we are on the main branch" | ||
git checkout main | ||
|
||
echo "Remove 'open' from any <details> tags" | ||
sed -r 's/<details id=([0-9]+) open>/<details id=\1>/g' README.md > tmp | ||
mv tmp README.md | ||
|
||
echo "Add 'open' to step TO_STEP" | ||
sed -r "s/<details id=$TO_STEP>/<details id=$TO_STEP open>/g" README.md > tmp | ||
mv tmp README.md | ||
|
||
echo "Update the STEP file to TO_STEP" | ||
echo "$TO_STEP" > .github/script/STEP | ||
|
||
echo "Commit the files, and push to main" | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add README.md | ||
git add .github/script/STEP | ||
git commit --message="Update to $TO_STEP in STEP and README.md" | ||
git push | ||
|
||
echo "If BRANCH_NAME, update that branch as well" | ||
if git show-ref --quiet refs/heads/$BRANCH_NAME | ||
then | ||
git checkout $BRANCH_NAME | ||
git cherry-pick main | ||
git push | ||
else | ||
echo "Branch $BRANCH_NAME does not exist" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Step 0, Start | ||
|
||
# This step triggers after the learner creates a new repository from the template | ||
# This step sets STEP to 1 | ||
# This step closes <details id=0> and opens <details id=1> | ||
|
||
# When creating a repository from a template, there is variability in the | ||
# order and timing of events that fire and when workflow triggers are registered. | ||
# Given that, these triggers are purposely broad to ensure this workflow is always triggered. | ||
# The conditions within the on_start job are to ensure it is only fully executed once. | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows | ||
on: | ||
create: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
# Need `contents: read` to checkout the repository | ||
# Need `contents: write` to update the step metadata | ||
contents: write | ||
|
||
jobs: | ||
get_current_step: | ||
name: Check current step number | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- id: get_step | ||
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)" | ||
outputs: | ||
current_step: ${{ steps.get_step.outputs.current_step }} | ||
|
||
on_start: | ||
name: On start | ||
needs: get_current_step | ||
|
||
# We will only run this action when: | ||
# 1. This repository isn't the template repository | ||
# 2. The STEP is currently '0' (see update-step.sh) | ||
# 3. This is the first workflow run on the repository | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions | ||
if: ${{ github.repository_owner != 'InfomagnusOrg' | ||
&& needs.get_current_step.outputs.current_step == 0 | ||
&& github.run_number == 1 }} | ||
|
||
# We'll run Ubuntu for performance instead of Mac or Windows | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# We'll need to check out the repository so that we can edit the README | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Let's get all the branches | ||
|
||
# Update README to close <details id=0> | ||
# and open <details id=1> | ||
# and set STEP to '1' | ||
- name: Update to step 1 | ||
run: ./.github/script/update-step.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FROM_STEP: 0 | ||
TO_STEP: 1 | ||
|
||
# This is required to establish a related history for branches | ||
# after being created from the template repository | ||
- name: Initialize repository | ||
run: ./.github/script/initialize-repository.sh --dry-run=false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Step 1, Resolve duplicate issues | ||
|
||
# This step triggers after 0-start.yml | ||
# This step sets STEP to 2 | ||
# This step closes <details id=1> and opens <details id=2> | ||
|
||
# This will run every time we update or close the issue | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows | ||
|
||
on: | ||
workflow_dispatch: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
permissions: | ||
# Need `contents: read` to checkout the repository | ||
# Need `contents: write` to update the step metadata | ||
contents: write | ||
|
||
jobs: | ||
|
||
get_current_step: | ||
name: Check current step number | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- id: get_step | ||
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)" | ||
outputs: | ||
current_step: ${{ steps.get_step.outputs.current_step }} | ||
|
||
on_duplicate_issue_closed: | ||
name: Check if duplicate issue is marked as duplicate | ||
needs: get_current_step | ||
|
||
# We will only run this action when: | ||
# 1. This repository isn't the template repository | ||
# 2. The STEP is currently 1 (see update-step.sh) | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions | ||
if: ${{ github.repository_owner != 'TBD-organization' }} | ||
&& needs.get_current_step.outputs.current_step == 1 }} | ||
|
||
# We'll run Ubuntu for performance instead of Mac or Windows | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# We'll need to check out the repository so that we can edit the README | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Let's get all the branches | ||
|
||
- name: Dump GitHub comment context | ||
id: github_comment_step | ||
run: echo '${{ toJSON(github.event.comment) }}' | ||
|
||
- name: Dump GitHub issue context | ||
id: github_issue_step | ||
run: echo '${{ toJSON(github.event.issue) }}' | ||
|
||
- name: Check if commented issue is closed and marked as duplicate | ||
if: ${{ contains(github.event.comment.body, 'Duplicate of') && (github.event.issue.state == 'closed')}} | ||
run: echo 'Duplicate issue closed' | ||
|
||
# Update README to close <details id=1> | ||
# and open <details id=2> | ||
# and set STEP to '2' | ||
- name: Update to step 2 | ||
run: ./.github/script/update-step.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FROM_STEP: 1 | ||
TO_STEP: 2 | ||
BRANCH_NAME: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Step 2, Find a commit in history | ||
|
||
# This step triggers after TBD-step-2-event-desc | ||
# This step sets STEP to 3 | ||
# This step closes <details id=2> and opens <details id=3> | ||
|
||
# This will run every time we TBD-step-2-event-desc | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows | ||
on: | ||
workflow_dispatch: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
permissions: | ||
# Need `contents: read` to checkout the repository | ||
# Need `contents: write` to update the step metadata | ||
contents: write | ||
|
||
env: | ||
FIND_COMMIT_ID: f3dcc803ace969b145b318bfbf6a9f3071b322f7 | ||
|
||
jobs: | ||
|
||
get_current_step: | ||
name: Check current step number | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- id: get_step | ||
run: echo "::set-output name=current_step::$(cat ./.github/script/STEP)" | ||
outputs: | ||
current_step: ${{ steps.get_step.outputs.current_step }} | ||
|
||
on_fix_the_sidebar_issue_comment: | ||
name: Check if the issue comment is referencing the correct commit ID | ||
needs: get_current_step | ||
|
||
# We will only run this action when: | ||
# 1. This repository isn't the template repository | ||
# 2. The STEP is currently 2 (see update-step.sh) | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts | ||
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions | ||
if: ${{ github.repository_owner != 'TBD-organization' }} | ||
&& needs.get_current_step.outputs.current_step == 2 }} | ||
|
||
# We'll run Ubuntu for performance instead of Mac or Windows | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# We'll need to check out the repository so that we can edit the README | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Let's get all the branches | ||
|
||
- name: Dump GitHub comment context | ||
id: github_comment_step | ||
run: echo '${{ toJSON(github.event.comment) }}' | ||
|
||
- name: Dump GitHub issue context | ||
id: github_issue_step | ||
run: echo '${{ toJSON(github.event.issue) }}' | ||
|
||
- name: Check if the isuees comments is referencing the required commit ID | ||
if: contains(github.event.comment.body, env.FIND_COMMIT_ID) | ||
run: echo 'Found the reference to required commit in the comment' | ||
|
||
# Update README to close <details id=2> | ||
# and open <details id=3> | ||
# and set STEP to '3' | ||
- name: Update to step 3 | ||
run: ./.github/script/update-step.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
FROM_STEP: 2 | ||
TO_STEP: 3 | ||
BRANCH_NAME: main |
Oops, something went wrong.
2 comments
on commit ff885ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ff885ef