From 45e92c2705b9038560894ac7431e7b1cdd83f307 Mon Sep 17 00:00:00 2001 From: "keroroxx520@gmail.com" Date: Thu, 4 Jul 2024 17:10:33 +0800 Subject: [PATCH] .github: copy from template repo --- .github/dependabot.yml | 6 ++ .github/steps/-step.txt | 1 + .github/steps/0-welcome.md | 1 + .github/steps/1-enable-github-pages.md | 24 +++++ .github/steps/2-configure-your-site.md | 29 ++++++ .github/steps/3-customize-your-homepage.md | 21 +++++ .github/steps/4-create-a-blog-post.md | 44 +++++++++ .github/steps/5-merge-your-pull-request.md | 17 ++++ .github/steps/X-finish.md | 27 ++++++ .github/workflows/0-welcome.yml | 94 +++++++++++++++++++ .github/workflows/1-enable-github-pages.yml | 63 +++++++++++++ .github/workflows/2-configure-your-site.yml | 67 +++++++++++++ .../workflows/3-customize-your-homepage.yml | 67 +++++++++++++ .github/workflows/4-create-a-blog-post.yml | 67 +++++++++++++ .../workflows/5-merge-your-pull-request.yml | 64 +++++++++++++ 15 files changed, 592 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/steps/-step.txt create mode 100644 .github/steps/0-welcome.md create mode 100644 .github/steps/1-enable-github-pages.md create mode 100644 .github/steps/2-configure-your-site.md create mode 100644 .github/steps/3-customize-your-homepage.md create mode 100644 .github/steps/4-create-a-blog-post.md create mode 100644 .github/steps/5-merge-your-pull-request.md create mode 100644 .github/steps/X-finish.md create mode 100644 .github/workflows/0-welcome.yml create mode 100644 .github/workflows/1-enable-github-pages.yml create mode 100644 .github/workflows/2-configure-your-site.yml create mode 100644 .github/workflows/3-customize-your-homepage.yml create mode 100644 .github/workflows/4-create-a-blog-post.yml create mode 100644 .github/workflows/5-merge-your-pull-request.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8ac6b8c --- /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 0000000..62d8fe9 --- /dev/null +++ b/.github/steps/-step.txt @@ -0,0 +1 @@ +X diff --git a/.github/steps/0-welcome.md b/.github/steps/0-welcome.md new file mode 100644 index 0000000..9ff13a5 --- /dev/null +++ b/.github/steps/0-welcome.md @@ -0,0 +1 @@ + diff --git a/.github/steps/1-enable-github-pages.md b/.github/steps/1-enable-github-pages.md new file mode 100644 index 0000000..f1ca23d --- /dev/null +++ b/.github/steps/1-enable-github-pages.md @@ -0,0 +1,24 @@ + + +## Step 1: Enable GitHub Pages + +_Welcome to GitHub Pages and Jekyll :tada:!_ + +The first step is to enable GitHub Pages on this [repository](https://docs.github.com/en/get-started/quickstart/github-glossary#repository). When you enable GitHub Pages on a repository, GitHub takes the content that's on the main branch and publishes a website based on its contents. + +### :keyboard: Activity: Enable GitHub Pages + +1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab. +1. Under your repository name, click **Settings**. +1. Click **Pages** in the **Code and automation** section. +1. Ensure "Deploy from a branch" is selected from the **Source** drop-down menu, and then select `main` from the **Branch** drop-down menu. +1. Click the **Save** button. +1. Wait about _one minute_ 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. + > Turning on GitHub Pages creates a deployment of your repository. GitHub Actions may take up to a minute to respond while waiting for the deployment. Future steps will be about 20 seconds; this step is slower. + > **Note**: In the **Pages** of **Settings**, the **Visit site** button will appear at the top. Click the button to see your GitHub Pages site. diff --git a/.github/steps/2-configure-your-site.md b/.github/steps/2-configure-your-site.md new file mode 100644 index 0000000..b470ada --- /dev/null +++ b/.github/steps/2-configure-your-site.md @@ -0,0 +1,29 @@ + + +## Step 2: Configure your site + +_You turned on GitHub Pages! :tada:_ + +We'll work in a branch, `my-pages`, that I created for you to get this site looking great. :sparkle: + +Jekyll uses a file titled `_config.yml` to store settings for your site, your theme, and reusable content like your site title and GitHub handle. You can check out the `_config.yml` file on the **Code** tab of your repository. + +We need to use a blog-ready theme. For this activity, we will use a theme named "minima". + +### :keyboard: Activity: Configure your site + +1. Browse to the `_config.yml` file in the `my-pages` branch. +1. In the upper right corner, open the file editor. +1. Add a `theme:` set to **minima** so it shows in the `_config.yml` file as below: + ```yml + theme: minima + ``` +1. (optional) You can modify the other configuration variables such as `title:`, `author:`, and `description:` to further customize your site. +1. Commit your changes. +1. (optional) Create a pull request to view all the changes you'll make throughout this course. Click the **Pull Requests** tab, click **New pull request**, set `base: main` and `compare:my-pages`. +1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step. diff --git a/.github/steps/3-customize-your-homepage.md b/.github/steps/3-customize-your-homepage.md new file mode 100644 index 0000000..547b57d --- /dev/null +++ b/.github/steps/3-customize-your-homepage.md @@ -0,0 +1,21 @@ + + +## Step 3: Customize your homepage + +_Nice work setting the theme! :sparkles:_ + +You can customize your homepage by adding content to either an `index.md` file or the `README.md` file. GitHub Pages first looks for an `index.md` file. Your repository has an `index.md` file so we can update it to include your personalized content. + +### :keyboard: Activity: Create your homepage + +1. Browse to the `index.md` file in the `my-pages` branch. +1. In the upper right corner, open the file editor. +1. Type the content you want on your homepage. You can use Markdown formatting on this page. +1. (optional) You can also modify `title:` or just ignore it for now. We'll discuss it in the next step. +1. Commit your changes to the `my-pages` branch. +1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step. diff --git a/.github/steps/4-create-a-blog-post.md b/.github/steps/4-create-a-blog-post.md new file mode 100644 index 0000000..cc75a60 --- /dev/null +++ b/.github/steps/4-create-a-blog-post.md @@ -0,0 +1,44 @@ + + +## Step 4: Create a blog post + +_Your home page is looking great! :cowboy_hat_face:_ + +GitHub Pages uses Jekyll. In Jekyll, we can create a blog by using specially named files and frontmatter. The files must be named `_posts/YYYY-MM-DD-title.md`. You must also include `title` and `date` in your frontmatter. + +**What is _frontmatter_?**: The syntax Jekyll files use is called YAML frontmatter. It goes at the top of your file and looks something like this: + +```yml +--- +title: "Welcome to my blog" +date: 2019-01-20 +--- +``` + +For more information about configuring front matter, see the [Jekyll frontmatter documentation](https://jekyllrb.com/docs/frontmatter/). + +### :keyboard: Activity: Create a blog post + +1. Browse to the `my-pages` branch. +1. Click the `Add file` dropdown menu and then on `Create new file`. +1. Name the file `_posts/YYYY-MM-DD-title.md`. +1. Replace the `YYYY-MM-DD` with today's date, and change the `title` of your first blog post if you'd like. + > If you do edit the title, make sure there are hyphens between your words. + > If your blog post date doesn't follow the correct date convention, you'll receive an error and your site won't build. For more information, see "[Page build failed: Invalid post date](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/troubleshooting-jekyll-build-errors-for-github-pages-sites)". +1. Type the following content at the top of your blog post: + ```yaml + --- + title: "YOUR-TITLE" + date: YYYY-MM-DD + --- + ``` +1. Replace `YOUR-TITLE` with the title for your blog post. +1. Replace `YYYY-MM-DD` with today's date. +1. Type a quick draft of your blog post. Remember, you can always edit it later. +1. Commit your changes to your branch. +1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step. diff --git a/.github/steps/5-merge-your-pull-request.md b/.github/steps/5-merge-your-pull-request.md new file mode 100644 index 0000000..31b46f5 --- /dev/null +++ b/.github/steps/5-merge-your-pull-request.md @@ -0,0 +1,17 @@ + + +## Step 5: Merge your pull request + +_Nice work, friend :heart:! People will be reading your blog in no time!_ + +You can now [merge](https://docs.github.com/en/get-started/quickstart/github-glossary#merge) your pull request! + +### :keyboard: Activity: Merge your changes + +1. Merge your changes from `my-pages` into `main`. If you created the pull request in step 2, just open that PR and click on **Merge pull request**. If you did not create the pull request earlier, you can do it now by following the instructions in [step 2](/.github/steps/2-configure-your-site.md). +1. (optional) Delete the branch `my-pages`. +1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step. diff --git a/.github/steps/X-finish.md b/.github/steps/X-finish.md new file mode 100644 index 0000000..62dccf3 --- /dev/null +++ b/.github/steps/X-finish.md @@ -0,0 +1,27 @@ + + +## Finish + +_Congratulations friend, you've completed this course!_ + +celebrate + +Your blog is now live and has been deployed! + +Here's a recap of all the tasks you've accomplished in your repository: + +- You enabled GitHub Pages. +- You selected a theme using the config file. +- You learned about proper directory format and file naming conventions in Jekyll. +- You created your first blog post with Jekyll! + +### What's next? + +- Keep working on your GitHub Pages site... we love seeing what you come up with! +- We'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/github-pages). +- [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-welcome.yml b/.github/workflows/0-welcome.yml new file mode 100644 index 0000000..dd51132 --- /dev/null +++ b/.github/workflows/0-welcome.yml @@ -0,0 +1,94 @@ +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. + # Need `pull-requests: write` to create a pull request. + contents: write + pull-requests: 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_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. + # 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 the README. + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Let's get all the branches. + + - name: Create my-pages branch, initial Pages files, and pull request + run: | + echo "Make sure we are on step 0" + if [ "$(cat .github/steps/-step.txt)" != 0 ] + then + echo "Current step is not 0" + exit 0 + fi + + echo "Make a branch" + BRANCH=my-pages + git checkout -b $BRANCH + + echo "Create config and homepage files" + touch _config.yml + printf "%s\n%s\n%s\n\n" "---" "title: Welcome to my blog" "---" > index.md + + echo "Make a commit" + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git add _config.yml index.md + git commit --message="Create config and homepages files" + + echo "Push" + git push --set-upstream origin $BRANCH + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # 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-pages diff --git a/.github/workflows/1-enable-github-pages.yml b/.github/workflows/1-enable-github-pages.yml new file mode 100644 index 0000000..4237d68 --- /dev/null +++ b/.github/workflows/1-enable-github-pages.yml @@ -0,0 +1,63 @@ +name: Step 1, Enable GitHub Pages + +# This step triggers after we run a pages build. +# This workflow updates from step 1 to step 2. + +# This will run every time we run a pages build. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows +on: + workflow_dispatch: + page_build: + +# 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_enable_github_pages: + name: On enable github pages + 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. + # 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 }} + + # 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 + with: + fetch-depth: 0 # Let's get all the branches. + ref: my-pages + + # 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-pages diff --git a/.github/workflows/2-configure-your-site.yml b/.github/workflows/2-configure-your-site.yml new file mode 100644 index 0000000..64bbf70 --- /dev/null +++ b/.github/workflows/2-configure-your-site.yml @@ -0,0 +1,67 @@ +name: Step 2, Configure your site + +# This step triggers after the learner update their Pages config file. +# This workflow updates from step 2 to step 3. + +# This will run every time we update `_config.yml` in the `my-pages` branch. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows +on: + workflow_dispatch: + push: + branches: + - my-pages + paths: + - _config.yml + +# 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_config_update: + name: On config update + 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 + + steps: + # We'll need to check out the repository so that we can edit the README. + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Let's get all the branches. + ref: my-pages + + # 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-pages diff --git a/.github/workflows/3-customize-your-homepage.yml b/.github/workflows/3-customize-your-homepage.yml new file mode 100644 index 0000000..a495b67 --- /dev/null +++ b/.github/workflows/3-customize-your-homepage.yml @@ -0,0 +1,67 @@ +name: Step 3, Customize your homepage + +# This step triggers after the learner updates their homepage. +# This workflow updates from step 3 to step 4. + +# This will run every time we update `index.md` in the `my-pages` branch. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows +on: + workflow_dispatch: + push: + branches: + - my-pages + paths: + - index.md + +# 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_homepage_update: + name: On homepage update + 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. + # 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 }} + + # 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 + with: + fetch-depth: 0 # Let's get all the branches. + ref: my-pages + + # 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-pages diff --git a/.github/workflows/4-create-a-blog-post.yml b/.github/workflows/4-create-a-blog-post.yml new file mode 100644 index 0000000..e7fa90b --- /dev/null +++ b/.github/workflows/4-create-a-blog-post.yml @@ -0,0 +1,67 @@ +name: Step 4, Create a blog post + +# This step triggers after the learner creates a blog post. +# This workflow updates from step 4 to step 5. + +# This will run every time we update a .md file in `_posts/` in the `my-pages` branch. +# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows +on: + workflow_dispatch: + push: + branches: + - my-pages + paths: + - _posts/*.md + +# 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_create_blog_post: + name: On create blog post + 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 + with: + fetch-depth: 0 # Let's get all the branches. + ref: my-pages + + # In README.md, switch step 4 for step 5. + - name: Update to step 5 + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 4 + to_step: 5 + branch_name: my-pages diff --git a/.github/workflows/5-merge-your-pull-request.yml b/.github/workflows/5-merge-your-pull-request.yml new file mode 100644 index 0000000..028714a --- /dev/null +++ b/.github/workflows/5-merge-your-pull-request.yml @@ -0,0 +1,64 @@ +name: Step 5, Merge your pull request + +# This step triggers after a pull requst is merged to `main`. +# This workflow updates from step 5 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: + 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_merge: + name: On merge + needs: get_current_step + + # We will only run this action when: + # 1. This repository isn't the template repository. + # 2. The step is currently 5. + # 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 == 5 }} + + # 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 + with: + fetch-depth: 0 # Let's get all the branches. + + # In README.md, switch step 5 for step X. + - name: Update to step X + uses: skills/action-update-step@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + from_step: 5 + to_step: X + branch_name: my-pages