From 45e4b06acac96555c2a618afd932924c1dfe1d4f Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:29:04 -0700 Subject: [PATCH 1/9] Add github workflow for PRs Add GitHub workflow for PR --- .github/workflows/pull-request.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..90f1f46 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,39 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on or pull request events but only for the mainline branch + pull_request: + branches: [ mainline ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a single command using the runners shell + - name: Setup Node.js environment + uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install dependencies πŸ“¦ + run: yarn install --frozen-lockfile + - name: Build πŸ›  + run: yarn build + - name: Deploy previewπŸ”Ž + run: yarn deploy:preview + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} From d7874d0f934c03d580245a3e28235743002cfd99 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:36:08 -0700 Subject: [PATCH 2/9] Extract draft URL --- .github/workflows/pull-request.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 90f1f46..228460b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -33,7 +33,10 @@ jobs: - name: Build πŸ›  run: yarn build - name: Deploy previewπŸ”Ž - run: yarn deploy:preview + run: yarn deploy:preview | tee output.log env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + - name: Extract draft url πŸ“ + run: cat output.log | fgrep "Website Draft URL" | echo + From d778674cc6360603851853eef46f08267fb8deed Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:40:21 -0700 Subject: [PATCH 3/9] Tmp --- .github/workflows/pull-request.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 228460b..1e2dd30 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -38,5 +38,17 @@ jobs: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - name: Extract draft url πŸ“ - run: cat output.log | fgrep "Website Draft URL" | echo - + run: | + cat output.log + URL=$(cat output.log | fgrep "Website Draft URL") + echo $URL + - name: comment PR + uses: unsplash/comment-on-pr@1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "Check out this message!" + check_for_duplicate_msg: false # OPTIONAL + delete_prev_regex_msg: "[0-9]" # OPTIONAL + duplicate_msg_pattern: "[A-Z]" # OPTIONAL + From 7df242dd71c0bab6f3c18a2b32aa6e71f9671eb9 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:43:25 -0700 Subject: [PATCH 4/9] 31r --- .github/workflows/pull-request.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1e2dd30..070cb15 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -42,13 +42,4 @@ jobs: cat output.log URL=$(cat output.log | fgrep "Website Draft URL") echo $URL - - name: comment PR - uses: unsplash/comment-on-pr@1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - msg: "Check out this message!" - check_for_duplicate_msg: false # OPTIONAL - delete_prev_regex_msg: "[0-9]" # OPTIONAL - duplicate_msg_pattern: "[A-Z]" # OPTIONAL From 4f845d0e17d1697af7adf1f5756a441b6a434eb3 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:48:52 -0700 Subject: [PATCH 5/9] print draft --- .github/workflows/pull-request.yml | 6 ++++-- .github/workflows/template.md | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/template.md diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 070cb15..3a1ecbe 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -38,8 +38,10 @@ jobs: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - name: Extract draft url πŸ“ + id: draft-url run: | - cat output.log URL=$(cat output.log | fgrep "Website Draft URL") echo $URL - + echo '::set-output name=DRAFT_URL::$URL' + - name: Print draft url πŸ“ + run: echo "The selected color is ${{ steps.draft-url.outputs.DRAFT_URL }}" diff --git a/.github/workflows/template.md b/.github/workflows/template.md new file mode 100644 index 0000000..648e071 --- /dev/null +++ b/.github/workflows/template.md @@ -0,0 +1 @@ +Check out the draft URL: From 719c0af8cea10a9b8f563e91a771d45d13c1edd8 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:52:44 -0700 Subject: [PATCH 6/9] Echo out the value --- .github/workflows/pull-request.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3a1ecbe..fcc3fdb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,14 +1,9 @@ -# This is a basic workflow to help you get started with Actions +name: Pull Requests -name: CI - -# Controls when the workflow will run on: - # Triggers the workflow on or pull request events but only for the mainline branch pull_request: branches: [ mainline ] - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel @@ -18,11 +13,22 @@ jobs: # The type of runner that the job will run on runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + # Runs a single command using the runners shell - name: Setup Node.js environment uses: actions/setup-node@v2 @@ -42,6 +48,8 @@ jobs: run: | URL=$(cat output.log | fgrep "Website Draft URL") echo $URL - echo '::set-output name=DRAFT_URL::$URL' + echo '::set-output name=DRAFT_URL::$(echo $URL)' + shell: bash - name: Print draft url πŸ“ run: echo "The selected color is ${{ steps.draft-url.outputs.DRAFT_URL }}" + shell: bash From 7410b7884e1ab51a7b3a91aae5fd3e32e6bdf498 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 15:57:39 -0700 Subject: [PATCH 7/9] Testing --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fcc3fdb..61a439b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -48,8 +48,8 @@ jobs: run: | URL=$(cat output.log | fgrep "Website Draft URL") echo $URL - echo '::set-output name=DRAFT_URL::$(echo $URL)' + echo ::set-output name=url::$(echo $URL) shell: bash - name: Print draft url πŸ“ - run: echo "The selected color is ${{ steps.draft-url.outputs.DRAFT_URL }}" + run: echo "The selected color is ${{ steps.draft-url.outputs.url }}" shell: bash From da712413540fdfe1e7eea6b1c72310d5f593ffd2 Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 16:03:07 -0700 Subject: [PATCH 8/9] add comment to PR --- .github/workflows/pull-request.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 61a439b..6b47886 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -50,6 +50,13 @@ jobs: echo $URL echo ::set-output name=url::$(echo $URL) shell: bash - - name: Print draft url πŸ“ - run: echo "The selected color is ${{ steps.draft-url.outputs.url }}" - shell: bash + - uses: mshick/add-pr-comment@v1 + with: + message: | + **Latest preview link** + 🌏 ${{ steps.draft-url.outputs.url }} + ! + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: false # This is the default + From 65124e131d1600bc1f770c85260434056fc1797b Mon Sep 17 00:00:00 2001 From: Andy Dang <26821974+andyndang@users.noreply.github.com> Date: Fri, 8 Oct 2021 16:06:32 -0700 Subject: [PATCH 9/9] Update messaging --- .github/workflows/pull-request.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6b47886..acb2be5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -54,8 +54,9 @@ jobs: with: message: | **Latest preview link** - 🌏 ${{ steps.draft-url.outputs.url }} - ! + + Please check out the preview link to ensure that the doc site renders correctly + 🌏 ${{ steps.draft-url.outputs.url }}! repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token-user-login: 'github-actions[bot]' allow-repeats: false # This is the default