diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..8ac6b8c49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/steps/-step.txt b/.github/steps/-step.txt new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/.github/steps/-step.txt @@ -0,0 +1 @@ +0 diff --git a/.github/steps/0-welcome.md b/.github/steps/0-welcome.md new file mode 100644 index 000000000..9ff13a5df --- /dev/null +++ b/.github/steps/0-welcome.md @@ -0,0 +1 @@ + diff --git a/.github/steps/1-create-a-branch.md b/.github/steps/1-create-a-branch.md index 5f3ee6ca5..4fe9b4897 100644 --- a/.github/steps/1-create-a-branch.md +++ b/.github/steps/1-create-a-branch.md @@ -1,61 +1,45 @@ + + ## Step 1: Create a branch _Welcome to "Introduction to GitHub"! :wave:_ -**What is GitHub?**: GitHub is a collaboration platform that uses _[Git](https://docs.github.com/get-started/quickstart/github-glossary#git)_ for versioning. -GitHub is a popular place to share and contribute to [open-source](https://docs.github.com/get-started/quickstart/github-glossary#open-source) software. - -:tv: [Video: What is GitHub?](https://www.youtube.com/watch?v=pBy1zgt0XPc) +**What is GitHub?**: GitHub is a collaboration platform that uses _[Git](https://docs.github.com/get-started/quickstart/github-glossary#git)_ for versioning. GitHub is a popular place to share and contribute to [open-source](https://docs.github.com/get-started/quickstart/github-glossary#open-source) software. +
:tv: [Video: What is GitHub?](https://www.youtube.com/watch?v=pBy1zgt0XPc) -**What is a repository?**: A _[repository](https://docs.github.com/get-started/quickstart/github-glossary#repository)_ is a project containing files and folders. -A repository tracks versions of files and folders. For more information, see -"[About repositories](https://docs.github.com/en/repositories/creating-and-managing-repositories/about-repositories)" from GitHub Docs. +**What is a repository?**: A _[repository](https://docs.github.com/get-started/quickstart/github-glossary#repository)_ is a project containing files and folders. A repository tracks versions of files and folders. For more information, see "[About repositories](https://docs.github.com/en/repositories/creating-and-managing-repositories/about-repositories)" from GitHub Docs. -**What is a branch?**: A _[branch](https://docs.github.com/en/get-started/quickstart/github-glossary#branch)_ is a parallel version of your repository. -By default, your repository has one branch named `main` and it is considered to be the definitive branch. -Creating additional branches allows you to copy the `main` branch of your repository and safely make any changes without disrupting the main project. -Many people use branches to work on specific features without affecting any other parts of the project. +**What is a branch?**: A _[branch](https://docs.github.com/en/get-started/quickstart/github-glossary#branch)_ is a parallel version of your repository. By default, your repository has one branch named `main` and it is considered to be the definitive branch. Creating additional branches allows you to copy the `main` branch of your repository and safely make any changes without disrupting the main project. Many people use branches to work on specific features without affecting any other parts of the project. -Branches allow you to separate your work from the `main` branch. -In other words, everyone's work is safe while you contribute. -For more information, see "[About branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches)". +Branches allow you to separate your work from the `main` branch. In other words, everyone's work is safe while you contribute. For more information, see "[About branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches)". -**What is a profile README?**: A _[profile README](https://docs.github.com/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme)_ -is essentially an "About me" section on your GitHub profile where you can share information about yourself with the community on GitHub.com. -GitHub shows your profile README at the top of your profile page. For more information, see "[Managing your profile README](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme)". +**What is a profile README?**: A _[profile README](https://docs.github.com/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme)_ is essentially an "About me" section on your GitHub profile where you can share information about yourself with the community on GitHub.com. GitHub shows your profile README at the top of your profile page. For more information, see "[Managing your profile README](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme)". -![screenshot showing an example profile readme](https://github.com/user-attachments/assets/fdc3a590-0bab-4758-9aec-6fd93c1d81a6) +![profile-readme-example](/images/profile-readme-example.png) ### :keyboard: Activity: Your first branch -1. Open a new browser tab and navigate to your newly made repository (your copy of this exercise). Then, work on the steps in your second tab while you read the instructions in this tab. - +1. Open a new browser tab and navigate to your newly made repository. Then, work on the steps in your second tab while you read the instructions in this tab. 2. Navigate to the **< > Code** tab in the header menu of your repository. - ![screenshot highlighting the code tab](https://github.com/user-attachments/assets/9a310b11-d80b-4b0f-bddc-aa41a8c01269) + ![code-tab](/images/code-tab.png) 3. Click on the **main** branch drop-down. - screenshot highlighting the branch selection - -4. In the text box **Find or create a branch...**, enter `my-first-branch`. - - > **Note:** This is checked to continue with the next step. :wink: - -5. Click the text **Create branch: `my-first-branch` from main** to create your branch. - - screenshot highlighting the create branch prompt - - - The branch will automatically switch to the one you just created. - - The **main** branch drop-down menu will display your new branch name. - -6. Now that your branch is pushed to GitHub, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson. + ![main-branch-dropdown](/images/main-branch-dropdown.png) +4. In the field, name your branch `my-first-branch`. In this case, the name must be `my-first-branch` to trigger the course workflow. +5. Click **Create branch: my-first-branch** to create your branch. -
-Having trouble? 🤷
+ ![create-branch-button](/images/create-branch-button.png) -If you don't get feedback, here are some things to check: -- Make sure your created the branch with the exact name `my-first-branch`. No prefixes or suffixes. + The branch will automatically switch to the one you have just created. + The **main** branch drop-down bar will reflect your new branch and display the new branch name. -
+6. 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. diff --git a/.github/steps/2-commit-a-file.md b/.github/steps/2-commit-a-file.md index 1067392c5..919102c39 100644 --- a/.github/steps/2-commit-a-file.md +++ b/.github/steps/2-commit-a-file.md @@ -1,3 +1,9 @@ + + ## Step 2: Commit a file _You created a branch! :tada:_ @@ -8,16 +14,16 @@ Creating a branch allows you to edit your project without changing the `main` br ### :keyboard: Activity: Your first commit -The following steps will guide you through the process of committing a change on GitHub. A commit records changes to the project such as adding/removing/renaming files and modifying file content. For this exercise, committing a change will be adding a new file to your new branch. +The following steps will guide you through the process of committing a change on GitHub. A commit records changes in renaming, changing content within, creating a new file, and any other changes made to your project. For this exercise, committing a change requires first adding a new file to your new branch. > [!NOTE] -> `.md` is a file extension that creates a Markdown file. You can learn more about Markdown by visiting "[Basic writing and formatting syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)" in our docs or by taking the "[Communicating using Markdown](https://github.com/skills/communicate-using-markdown)" Skills Exercise. +> `.md` is a file extension that creates a Markdown file. You can learn more about Markdown by visiting "[Basic writing and formatting syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)" in our docs or by taking the "[Communicating using Markdown](https://github.com/skills/communicate-using-markdown)" Skills course. 1. On the **< > Code** tab in the header menu of your repository, make sure you're on your new branch `my-first-branch`. 2. Select the **Add file** drop-down and click **Create new file**. - screenshot of the create new file option + ![create new file option](/images/create-new-file.png) 3. In the **Name your file...** field, enter `PROFILE.md`. @@ -27,26 +33,11 @@ The following steps will guide you through the process of committing a change on Welcome to my GitHub profile! ``` - ![screenshot for adding the profile.md file](https://github.com/user-attachments/assets/487c0ba4-88d8-4634-8715-a170413369d0) - -5. Click **Commit changes...** in the upper right corner above the contents box. A dialog will appear. - -6. GitHub offers a simple default message, but let's change it slightly for practice. Enter `Add PROFILE.md` in the **Commit message** field. - - - A **commit message** and optional **extended description** help provide clarity for your changes. This is particularly useful when your commit involves several files. - - screenshot of adding a new file with a commit message - -6. In this lesson, we'll ignore the other fields for now and click **Commit changes**. - -7. Now that you've changed a file, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson. - + ![profile.md file screenshot](/images/my-profile-file.png) -
-Having trouble? 🤷
+5. Click **Commit changes...** in the upper right corner above the contents box. For commits, you can enter a short commit message that describes what changes you made. This message helps others know what's included in your commit. GitHub offers a simple default message, but let's change it slightly for practice. First, enter `Add PROFILE.md` in the first text-entry field titled "Commit message". -If you don't get feedback, here are some things to check: -- Make sure you are on the `my-first-branch` branch. -- Ensure the `PROFILE.md` file is created and in the root folder. + ![screenshot of adding a new file with a commit message](/images/commit-full-screen.png) -
+6. In this lesson, we'll ignore the other fields and click **Commit changes**. +7. 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. diff --git a/.github/steps/3-open-a-pull-request.md b/.github/steps/3-open-a-pull-request.md index cf873c9f8..ed9cba0b6 100644 --- a/.github/steps/3-open-a-pull-request.md +++ b/.github/steps/3-open-a-pull-request.md @@ -1,3 +1,11 @@ + + ## Step 3: Open a pull request _Nice work making that commit! :sparkles:_ @@ -10,37 +18,27 @@ Now that you have made a change to the project and created a commit, it’s time You may have noticed after your commit that a message displayed indicating your recent push to your branch and providing a button that says **Compare & pull request**. -![screenshot of message and button](https://github.com/user-attachments/assets/a9f29bd2-0461-4bf9-9935-67730761bcd3) - -To create a pull request automatically, click **Compare & pull request** button, and then skip to step 5 below. Alternately, you practice creating it manually using the first 4 steps. - -1. In the header menu of your repository, click the **Pull requests** tab . -2. Click the **New pull request** button. -3. Select the following branches using the dropdown menus. - - - **base:** `main` - - **compare:** `my-first-branch` - - ![screenshot showing both branch selections](https://github.com/user-attachments/assets/8f01524c-c973-4f4f-a75c-0717fe09b664) - -4. Click **Create pull request**. - -5. Enter a title for your pull request. By default, the title will automatically be the name of your branch. For this exercise, let's edit the field to say `Add my first file`. - -6. The next field helps you provide a **description** of the changes you made. Please enter a short description of what you’ve accomplished so far. As a reminder, you have: created a new branch, created a file, and made a commit. +![screenshot of message and button](/images/compare-and-pull-request.png) - ![screenshot showing pull request](https://github.com/user-attachments/assets/c6e6af6b-d31e-4628-91ac-de6adb5b390c) +To create a pull request automatically, click **Compare & pull request**, and then skip to step 6 below. If you don't click the button, the instructions below walk you through manually setting up the pull request. -7. Click **Create pull request**. +1. Click on the **Pull requests** tab in the header menu of your repository. +2. Click **New pull request**. +3. In the **base:** dropdown, make sure **main** is selected. +4. Select the **compare:** dropdown, and click `my-first-branch`. -8. Now that you've started a place to collaborate, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson. + ![screenshot showing both branch selections](/images/pull-request-branches.png) +5. Click **Create pull request**. +6. Enter a title for your pull request. By default, the title will automatically be the name of your branch. For this exercise, let's edit the field to say `Add my first file`. +7. The next field helps you provide a description of the changes you made. Here, you can add a description of what you’ve accomplished so far. As a reminder, you have: created a new branch, created a file, and made a commit. -
-Having trouble? 🤷
+ ![screenshot showing pull request](/images/Pull-request-description.png) -If you don't get feedback, here are some things to check: -- Make sure your pull request title is correct. -- Ensure your pull request has a description. +8. Click **Create pull request**. You will automatically be navigated to your new pull request. +9. 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. -
+> [!NOTE] +> You may see evidence of GitHub Actions running on the tab with the pull request opened! The image below shows a line you might see on your pull request after the Action finishes running. +> +> ![screenshot of an example of an actions line](/images/Actions-to-step-4.png) diff --git a/.github/steps/4-merge-your-pull-request.md b/.github/steps/4-merge-your-pull-request.md index 465e2ab8d..6b26b90a7 100644 --- a/.github/steps/4-merge-your-pull-request.md +++ b/.github/steps/4-merge-your-pull-request.md @@ -1,33 +1,31 @@ + + ## Step 4: Merge your pull request _Nicely done! :sunglasses:_ -You successfully created a pull request. Now it's time to merge it! +You successfully created a pull request. You can now merge your pull request. **What is a merge?**: A _[merge](https://docs.github.com/en/get-started/quickstart/github-glossary#merge)_ adds the changes in your pull request and branch into the `main` branch. For more information about merges, see "[Merging a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request)." -![screenshot of green merge pull request button](https://github.com/user-attachments/assets/c691b064-0bd3-4448-bdcd-b1ad82fc9154) +As noted in the previous step, you may have seen evidence of GitHub Actions running which automatically progresses your instructions to the next step. You'll have to wait for it to finish before you can merge your pull request. It will be ready when the merge pull request button is green. + +![screenshot of green merge pull request button](/images/Green-merge-pull-request.png) ### :keyboard: Activity: Merge the pull request 1. Click **Merge pull request**. - - > **Note:** You may see workflows running on your new pull request, causing the merge button to be inactive. Just wait a moment for them to finish and the merge button will activate. - 2. Click **Confirm merge**. - - > **Tip:** Did you notice this dialog looks similar to adding a file? A merge is also a kind of commit! - 3. Once your branch has been merged, you don't need it anymore. To delete this branch, click **Delete branch**. - ![screenshot showing delete branch button](https://github.com/user-attachments/assets/29ddff73-865b-485c-abc6-3333bca71b76) - -4. Now that your work is merged, Mona will confirm and share some final review content. Nice work! 🎉 - -
-Having trouble? 🤷
+ ![screenshot showing delete branch button](/images/delete-branch.png) -If you don't get feedback, here are some things to check: -- Make sure you completed the previous lessons. If they haven't passed, the merge button will be gray. +4. 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. -
+> [!NOTE] +> Check out the **Finish** step to see what you can learn next! diff --git a/.github/steps/x-review.md b/.github/steps/X-finish.md similarity index 75% rename from .github/steps/x-review.md rename to .github/steps/X-finish.md index ae249894f..8127bb231 100644 --- a/.github/steps/x-review.md +++ b/.github/steps/X-finish.md @@ -1,6 +1,11 @@ -## Review + -_Congratulations, you've completed this Exercise and joined the world of developers!_ +## Finish + +_Congratulations, you've completed this course and joined the world of developers!_ celebrate @@ -19,11 +24,11 @@ If you'd like to make a profile README, use the quickstart instructions below or 2. Create a file named `README.md` in its root. The "root" means not inside any folder in your repository. 3. Edit the contents of the `README.md` file. 4. If you created a new branch for your file, open and merge a pull request on your branch. -5. Lastly, we'd love to hear what you thought of this exercise [in our discussion board](https://github.com/orgs/skills/discussions/categories/introduction-to-github). +5. Lastly, we'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/introduction-to-github). Check out these resources to learn more or get involved: - Are you a student? Check out the [Student Developer Pack](https://education.github.com/pack). -- [Take another GitHub Skills exercise](https://skills.github.com). +- [Take another GitHub Skills course](https://github.com/skills). - [Read the GitHub Getting Started docs](https://docs.github.com/en/get-started). - To find projects to contribute to, check out [GitHub Explore](https://github.com/explore). diff --git a/.github/workflows/0-start-exercise.yml b/.github/workflows/0-start-exercise.yml deleted file mode 100644 index ec269351d..000000000 --- a/.github/workflows/0-start-exercise.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Step 0 # Start Exercise - -on: - push: - branches: - - main - -permissions: - contents: write # Update Readme - actions: write # Disable/enable workflows - issues: write # Create issue and comment on issues - - -env: - STEP_1_FILE: ".github/steps/1-create-a-branch.md" - -jobs: - start_exercise: - if: | - !github.event.repository.is_template - name: Start Exercise - uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.4.0 - with: - exercise-title: "Introduction to GitHub" - intro-message: "If you are new to GitHub, you might find your fellow developers use ___**issues**___ to organize their work and collaborate. We will do the same! That's another lesson, but today, we will introduce you to the basics." - - - post_next_step_content: - name: Post next step content - runs-on: ubuntu-latest - needs: [start_exercise] - env: - ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file ${{ env.STEP_1_FILE }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create comment - watching for progress - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Disable current workflow and enable next one - run: | - gh workflow enable "Step 1" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/0-welcome.yml b/.github/workflows/0-welcome.yml new file mode 100644 index 000000000..1ee77397f --- /dev/null +++ b/.github/workflows/0-welcome.yml @@ -0,0 +1,64 @@ +name: Step 0, Welcome + +# This step triggers after the learner creates a new repository from the template. +# This workflow updates from step 0 to step 1. + +# This will run every time we create push a commit to `main`. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows +on: + workflow_dispatch: + push: + branches: + - main + +# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication +permissions: + # Need `contents: read` to checkout the repository. + # Need `contents: write` to update the step metadata. + contents: write + +jobs: + # Get the current step to only run the main job when the learner is on the same step. + get_current_step: + name: Check current step number + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - id: get_step + run: | + echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT + outputs: + current_step: ${{ steps.get_step.outputs.current_step }} + + on_welcome: + name: On welcome + 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. + # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts + # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions + if: >- + ${{ !github.event.repository.is_template + && needs.get_current_step.outputs.current_step == 0 }} + + # 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 README.md. + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Let's get all the branches. + + # In README.md, switch step 0 for step 1. + - name: Update to step 1 + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 0 + to_step: 1 + branch_name: my-first-branch diff --git a/.github/workflows/1-create-a-branch.yml b/.github/workflows/1-create-a-branch.yml index a6977e9a4..5dd9cbe69 100644 --- a/.github/workflows/1-create-a-branch.yml +++ b/.github/workflows/1-create-a-branch.yml @@ -1,105 +1,66 @@ -name: Step 1 # Create a branch +name: Step 1, Create a branch -# Checks if the learner completed tasks for step 1. -# - Triggers when the user creates a new branch 'my-first-branch'. -# - Checks that the branch name is 'my-first-branch'. -# - If all checks pass, the workflow is disabled so it doesn't run again. As such, workflow status badge will change to green. +# This step listens for the learner to create branch `my-first-branch`. +# This workflow updates from step 1 to step 2. +# This will run every time we create a branch or tag. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows on: - push: - branches: - - "my-first-branch" + workflow_dispatch: + create: +# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication permissions: - contents: read - actions: write - issues: write - -env: - STEP_2_FILE: ".github/steps/2-commit-a-file.md" + # Need `contents: read` to checkout the repository. + # Need `contents: write` to update the step metadata. + contents: write jobs: - find_exercise: - name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0 - - check_step_work: - name: Check step work + # Get the current step to only run the main job when the learner is on the same step. + get_current_step: + name: Check current step number runs-on: ubuntu-latest - needs: find_exercise - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - steps: - - - name: Get response templates + - name: Checkout uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - - name: Update comment - checking work + - id: get_step run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build message - step finished - id: build-message-step-finish - uses: skills/action-text-variables@v1 - with: - template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md - template-vars: | - next_step_number=2 - - - name: Update comment - step finished - run: | - gh issue comment "$ISSUE_URL" \ - --body "$ISSUE_BODY" \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_BODY: ${{ steps.build-message-step-finish.outputs.updated-text }} - - post_next_step_content: - name: Post next step content - needs: [find_exercise, check_step_work] + echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT + outputs: + current_step: ${{ steps.get_step.outputs.current_step }} + + on_create_a_branch: + name: On create a branch + 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. + # 3. The event is a branch. + # 4. The branch name is `my-first-branch`. + # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts + # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions + if: >- + ${{ !github.event.repository.is_template + && needs.get_current_step.outputs.current_step == 1 + && github.ref_type == 'branch' + && github.ref_name == 'my-first-branch' }} + + # We'll run Ubuntu for performance instead of Mac or Windows. runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} steps: + # We'll need to check out the repository so that we can edit the README. - name: Checkout uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file ${{ env.STEP_2_FILE }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create comment - watching for progress - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 # Let's get all the branches. - - name: Disable current workflow and enable next one - run: | - gh workflow disable "Step 1" - gh workflow enable "Step 2" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # In README.md, switch step 1 for step 2. + - name: Update to step 2 + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 1 + to_step: 2 + branch_name: my-first-branch diff --git a/.github/workflows/2-commit-a-file.yml b/.github/workflows/2-commit-a-file.yml index bf6aa5995..bfa74d828 100644 --- a/.github/workflows/2-commit-a-file.yml +++ b/.github/workflows/2-commit-a-file.yml @@ -1,115 +1,64 @@ -name: Step 2 # Commit a file +name: Step 2, Commit a file -# Checks if the learner completed tasks for step 2. -# - Triggers when the user makes a push to the branch 'my-first-branch' and modifies the file 'PROFILE.md'. -# - If all checks pass, the workflow is disabled so it doesn't run again. As such, workflow status badge will change to green. +# This step listens for the learner to commit a file to branch `my-first-branch`. +# This workflow updates from step 2 to step 3. +# This action will run every time there's a push to `my-first-branch`. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows on: + workflow_dispatch: push: branches: - - "my-first-branch" + - my-first-branch +# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication permissions: - contents: read - actions: write - issues: write - -env: - STEP_3_FILE: ".github/steps/3-open-a-pull-request.md" - + # Need `contents: read` to checkout the repository. + # Need `contents: write` to update the step metadata. + contents: write jobs: - find_exercise: - name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0 - - check_step_work: - name: Check step work + # Get the current step to only run the main job when the learner is on the same step. + get_current_step: + name: Check current step number runs-on: ubuntu-latest - needs: find_exercise - if: | - !github.event.repository.is_template - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - steps: - name: Checkout uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - - name: Update comment - checking work - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # START: Check practical exercise - - # Nothing to verify. Creating the PROFILE.md file is enough. - - # END: Check practical exercise - - - - name: Build message - step finished - id: build-message-step-finish - uses: skills/action-text-variables@v1 - with: - template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md - template-vars: | - next_step_number=3 - - - name: Update comment - step finished + - id: get_step run: | - gh issue comment "$ISSUE_URL" \ - --body "${{ steps.build-message-step-finish.outputs.updated-text }}" \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_next_step_content: - name: Post next step content - needs: [find_exercise, check_step_work] + echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT + outputs: + current_step: ${{ steps.get_step.outputs.current_step }} + + on_commit_a_file: + name: On commit a file + 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. + # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts + # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions + if: >- + ${{ !github.event.repository.is_template + && needs.get_current_step.outputs.current_step == 2 }} + + # We'll run Ubuntu for performance instead of Mac or Windows. runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} steps: + # We'll need to check out the repository so that we can edit the README. - name: Checkout uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 + fetch-depth: 0 # Let's get all the branches. - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file ${{ env.STEP_3_FILE }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create comment - watching for progress - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Disable current workflow and enable next one - run: | - gh workflow disable "Step 2" - gh workflow enable "Step 3" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # In README.md, switch step 2 for step 3. + - name: Update to step 3 + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 2 + to_step: 3 + branch_name: my-first-branch diff --git a/.github/workflows/3-open-a-pull-request.yml b/.github/workflows/3-open-a-pull-request.yml index 1bbdfbda0..23c636c26 100644 --- a/.github/workflows/3-open-a-pull-request.yml +++ b/.github/workflows/3-open-a-pull-request.yml @@ -1,183 +1,68 @@ -name: Step 3 # Open a pull request +name: Step 3, Open a pull request -# Checks if the learner completed tasks for step 3. -# - Triggers when the user creates or edits the pull request. -# - Checks the pull request title and description. Adds a PR comment. -# - If all checks pass, the workflow is disabled so it doesn't run again. As such, workflow status badge will change to green. +# This step listens for the learner to open a pull request with branch `my-first-branch`. +# This workflow updates from step 3 to step 4. +# This will run every time we create a branch or tag. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows on: + workflow_dispatch: pull_request: - branches: - - main types: - opened - - synchronize - reopened - - edited +# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication permissions: - contents: read - actions: write - issues: write - -env: - STEP_4_FILE: ".github/steps/4-merge-your-pull-request.md" + # Need `contents: read` to checkout the repository. + # Need `contents: write` to update the step metadata. + contents: write jobs: - find_exercise: - name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0 - - check_step_work: - name: Check step work + # Get the current step to only run the main job when the learner is on the same step. + get_current_step: + name: Check current step number runs-on: ubuntu-latest - needs: find_exercise - if: | - !github.event.repository.is_template && - github.head_ref == 'my-first-branch' - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - steps: - name: Checkout uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - name: Update comment - congratulate first PR - run: | - message="You've created your first pull request. Nice work! ✨🎉 Now, let's check your work." - gh issue comment "$ISSUE_URL" \ - --body "$message" \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Check user work - id: check-user-work + - id: get_step run: | - # Checks to perform - checks='{ - "pr_title": { - "name": "Pull request title", - "passed": true, - "message": "" - }, - "pr_description": { - "name": "Pull request description", - "passed": true, - "message": "" - } - }' - - # Check pull request title - if [ "${{ github.event.pull_request.title }}" != "Add my first file" ]; then - checks=$(echo $checks | jq '.pr_title.passed = false') - checks=$(echo $checks | jq '.pr_title.message = "Incorrect title"') - fi - - # Check if a pull request description exists - if [ "${{ github.event.pull_request.body }}" == "" ]; then - checks=$(echo $checks | jq '.pr_description.passed = false') - checks=$(echo $checks | jq '.pr_description.message = "Empty pull request description"') - fi - - # Verify all checks passed - passed=$(echo $checks | jq '. | all(.passed?)') - - # Flatten to an array for returning. Allows iteration during rendering. - results=$(echo $checks | jq 'to_entries | map({name: .key} + .value)') - - # Save pass status to output - echo "passed=$passed" >> $GITHUB_OUTPUT - - # Save results to output - echo 'results<> $GITHUB_OUTPUT - echo $results >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT - - - name: Build message - step results - id: build-message-step-results - uses: skills/action-text-variables@v1 - with: - template-file: exercise-toolkit/markdown-templates/step-feedback/step-results.md - template-vars: '{ - "step_number": 3, - "passed": ${{ steps.check-user-work.outputs.passed }}, - "results_table": ${{ steps.check-user-work.outputs.results }}, - "tips": [ - "Issues are for capturing a problem/idea and possible solutions.", - "Pull requests are for active development and getting feedback." - ] - }' - - - name: Create comment - step results - run: | - gh issue comment "$ISSUE_URL" \ - --body "${{ steps.build-message-step-results.outputs.updated-text }}" \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Fail job if not all checks passed - if: steps.check-user-work.outputs.passed == 'false' - run: exit 1 - - - name: Build message - step finished - id: build-message-step-finish - uses: skills/action-text-variables@v1 - with: - template-file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md - template-vars: | - next_step_number=4 - - - name: Update comment - step finished - run: | - gh issue comment "$ISSUE_URL" \ - --body "${{ steps.build-message-step-finish.outputs.updated-text }}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_step_4_content: - name: Post step 4 content - needs: [find_exercise, check_step_work] + echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT + outputs: + current_step: ${{ steps.get_step.outputs.current_step }} + + on_open_a_pull_request: + name: On open a pull request + needs: get_current_step + + # We will only run this action when: + # 1. This repository isn't the template repository. + # 2. The step is currently 3. + # 3. The head branch name is `my-first-branch`. + # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts + # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions + if: >- + ${{ !github.event.repository.is_template + && needs.get_current_step.outputs.current_step == 3 + && github.head_ref == 'my-first-branch' }} + + # We'll run Ubuntu for performance instead of Mac or Windows. runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} steps: + # We'll need to check out the repository so that we can edit the README. - name: Checkout uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file ${{ env.STEP_4_FILE }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 # Let's get all the branches. + ref: my-first-branch # Important, as normally `pull_request` event won't grab other branches. - - name: Create comment - watching for progress - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Disable current workflow and enable next one - run: | - gh workflow disable "Step 3" - gh workflow enable "Step 4" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # In README.md, switch step 3 for step 4. + - name: Update to step 4 + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 3 + to_step: 4 + branch_name: my-first-branch diff --git a/.github/workflows/4-merge-your-pull-request.yml b/.github/workflows/4-merge-your-pull-request.yml index b0993113b..ae2e4bc65 100644 --- a/.github/workflows/4-merge-your-pull-request.yml +++ b/.github/workflows/4-merge-your-pull-request.yml @@ -1,97 +1,64 @@ -name: Step 4 # Merge your pull request +name: Step 4, Merge your pull request -# Checks if the learner completed tasks for step 4. -# - Triggers when the user merges the pull request. -# - If all checks pass, the workflow is disabled so it doesn't run again. As such, workflow status badge will change to green. +# This step listens for the learner to merge a pull request with branch `my-first-branch`. +# This workflow updates from step 4 to step X. +# This will run every time we create push a commit to `main`. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows on: - pull_request: + workflow_dispatch: + push: branches: - main - types: - - closed +# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication permissions: + # Need `contents: read` to checkout the repository. + # Need `contents: write` to update the step metadata. contents: write - actions: write - issues: write - -env: - REVIEW_FILE: ".github/steps/x-review.md" jobs: - find_exercise: - name: Find Exercise Issue - uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0 - - check_step_work: - name: Check step work - needs: find_exercise - runs-on: ubuntu-latest - if: | - !github.event.repository.is_template && - github.head_ref == 'my-first-branch' && - github.event.pull_request.merged == true - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/exercise-toolkit - path: exercise-toolkit - ref: v0.1.0 - - - name: Nothing to check - run: echo "The workflow was triggered, so it passes." - - - name: Update comment - step finished - final review next - run: | - gh issue comment "$ISSUE_URL" \ - --body-file exercise-toolkit/markdown-templates/step-feedback/lesson-review.md \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_review_content: - name: Post review content - needs: [find_exercise, check_step_work] + # Get the current step to only run the main job when the learner is on the same step. + get_current_step: + name: Check current step number runs-on: ubuntu-latest - if: | - !github.event.repository.is_template - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - steps: - name: Checkout uses: actions/checkout@v4 - - - name: Create comment - add review content + - id: get_step run: | - gh issue comment "$ISSUE_URL" \ - --body-file ${{ env.REVIEW_FILE }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - finish_exercise: - name: Finish Exercise - needs: [find_exercise, post_review_content] - uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.4.0 - with: - issue-url: ${{ needs.find_exercise.outputs.issue-url }} - - - disable_workflow: - name: Disable this workflow - needs: [find_exercise, post_review_content] + echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT + outputs: + current_step: ${{ steps.get_step.outputs.current_step }} + + on_merge_your_pull_request: + name: On merge your pull request + needs: get_current_step + + # We will only run this action when: + # 1. This repository isn't the template repository. + # 2. The step is currently 4. + # Reference: https://docs.github.com/en/actions/learn-github-actions/contexts + # Reference: https://docs.github.com/en/actions/learn-github-actions/expressions + if: >- + ${{ !github.event.repository.is_template + && needs.get_current_step.outputs.current_step == 4 }} + + # 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@v4 - - name: Disable current workflow - run: gh workflow disable "${{github.workflow}}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + fetch-depth: 0 # Let's get all the branches. + # In README.md, switch step 4 for step X. + - name: Update to step X + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 4 + to_step: X + branch_name: my-first-branch diff --git a/README.md b/README.md index 6331fa595..79ea84fca 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,74 @@ +
+ + + # Introduction to GitHub _Get started using GitHub in less than an hour._ +
+ + + ## Welcome -People use GitHub to build some of the most advanced technologies in the world. Whether you’re visualizing data or building a new game, there’s a whole community and set of tools on GitHub that can help you do it even better. GitHub Skills’ “Introduction to GitHub” exercise guides you through everything you need to start contributing in less than an hour. +People use GitHub to build some of the most advanced technologies in the world. Whether you’re visualizing data or building a new game, there’s a whole community and set of tools on GitHub that can help you do it even better. GitHub Skills’ “Introduction to GitHub” course guides you through everything you need to start contributing in less than an hour. - **Who is this for**: New developers, new GitHub users, and students. - **What you'll learn**: We'll introduce repositories, branches, commits, and pull requests. - **What you'll build**: We'll make a short Markdown file you can use as your [profile README](https://docs.github.com/account-and-profile/setting-up-and-managing-your-github-profile/customizing-your-profile/managing-your-profile-readme). -- **Prerequisites**: None. This exercise is a great introduction for your first day on GitHub. -- **How long**: This exercise takes less than one hour to complete. +- **Prerequisites**: None. This course is a great introduction for your first day on GitHub. +- **How long**: This course takes less than one hour to complete. -In this exercise, you will: +In this course, you will: 1. Create a branch 2. Commit a file 3. Open a pull request 4. Merge your pull request -### How to start this exercise - -Simply copy the exercise to your account, then give your favorite Octocat (Mona) **about 20 seconds** to prepare the first lesson, then **refresh the page**. +### How to start this course -[![](https://img.shields.io/badge/Copy%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](https://github.com/new?template_owner=skills&template_name=introduction-to-github&owner=%40me&name=skills-introduction-to-github&description=Exercise:+Introduction+to+GitHub&visibility=public) + -
-Having trouble? 🤷
+[![start-course](https://user-images.githubusercontent.com/1221423/235727646-4a590299-ffe5-480d-8cd5-8194ea184546.svg)](https://github.com/new?template_owner=skills&template_name=introduction-to-github&owner=%40me&name=skills-introduction-to-github&description=My+clone+repository&visibility=public) -When copying the exercise, we recommend the following settings: +1. Right-click **Start course** and open the link in a new tab. +2. In the new tab, most of the prompts will automatically fill in for you. + - For owner, choose your personal account or an organization to host the repository. + - We recommend creating a public repository, as private repositories will [use Actions minutes](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions). + - Scroll down and click the **Create repository** button at the bottom of the form. +3. After your new repository is created, wait about 20 seconds, then refresh the page. Follow the step-by-step instructions in the new repository's README. -- For owner, choose your personal account or an organization to host the repository. +
+Get help: [Post in our discussion board](https://github.com/orgs/skills/discussions/categories/introduction-to-github) • [Review the GitHub status page](https://www.githubstatus.com/) ---- +© 2024 GitHub • [Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) • [MIT License](https://gh.io/mit) -© 2025 GitHub • [Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) • [MIT License](https://gh.io/mit) + diff --git a/images/Actions-to-step-4.png b/images/Actions-to-step-4.png new file mode 100644 index 000000000..6b4c23f07 Binary files /dev/null and b/images/Actions-to-step-4.png differ diff --git a/images/Green-merge-pull-request.png b/images/Green-merge-pull-request.png new file mode 100644 index 000000000..b174895b0 Binary files /dev/null and b/images/Green-merge-pull-request.png differ diff --git a/images/Pull-request-description.png b/images/Pull-request-description.png new file mode 100644 index 000000000..2749e3a38 Binary files /dev/null and b/images/Pull-request-description.png differ diff --git a/images/code-tab.png b/images/code-tab.png new file mode 100644 index 000000000..f1965ae7f Binary files /dev/null and b/images/code-tab.png differ diff --git a/images/commit-full-screen.png b/images/commit-full-screen.png new file mode 100644 index 000000000..23f0831f4 Binary files /dev/null and b/images/commit-full-screen.png differ diff --git a/images/compare-and-pull-request.png b/images/compare-and-pull-request.png new file mode 100644 index 000000000..b083ebf12 Binary files /dev/null and b/images/compare-and-pull-request.png differ diff --git a/images/create-branch-button.png b/images/create-branch-button.png new file mode 100644 index 000000000..5b15fae52 Binary files /dev/null and b/images/create-branch-button.png differ diff --git a/images/create-new-file.png b/images/create-new-file.png new file mode 100644 index 000000000..f4a09191d Binary files /dev/null and b/images/create-new-file.png differ diff --git a/images/create-new-repository.png b/images/create-new-repository.png new file mode 100644 index 000000000..2a0ce2048 Binary files /dev/null and b/images/create-new-repository.png differ diff --git a/images/delete-branch.png b/images/delete-branch.png new file mode 100644 index 000000000..ccd6b4c9e Binary files /dev/null and b/images/delete-branch.png differ diff --git a/images/main-branch-dropdown.png b/images/main-branch-dropdown.png new file mode 100644 index 000000000..da6075b00 Binary files /dev/null and b/images/main-branch-dropdown.png differ diff --git a/images/my-profile-file.png b/images/my-profile-file.png new file mode 100644 index 000000000..ae7ffd68b Binary files /dev/null and b/images/my-profile-file.png differ diff --git a/images/profile-readme-example.png b/images/profile-readme-example.png new file mode 100644 index 000000000..27a048e85 Binary files /dev/null and b/images/profile-readme-example.png differ diff --git a/images/pull-request-branches.png b/images/pull-request-branches.png new file mode 100644 index 000000000..be84f0c35 Binary files /dev/null and b/images/pull-request-branches.png differ