From 91b6a4dacd046cfa2f28188da590da1eb5c67fb4 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:36:56 +0000 Subject: [PATCH 1/8] Update preview --- .github/workflows/preview.yaml | 80 +++------------------------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 088cfea1f..a7a071ee6 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -6,96 +6,26 @@ on: - main - "release-*" -permissions: - actions: none - checks: none - contents: read - deployments: none - issues: none - packages: none - pull-requests: write - repository-projects: none - security-events: none - statuses: none - -# Cancel in-progress runs for pull requests when developers push -# additional changes, and serialize builds in branches. -# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - jobs: preview: name: Preview - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - name: Checkout m - uses: actions/checkout@v3 - with: - repository: cdr/m - ref: refs/heads/master - ssh-key: ${{ secrets.READONLY_M_DEPLOY_KEY }} - submodules: true - fetch-depth: 0 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 14 - - - name: Cache Node Modules - uses: actions/cache@v2 - with: - path: "/node_modules" - key: node-${{ hashFiles('yarn.lock') }} - - - name: Create Deployment - id: deployment - run: ./ci/scripts/github_deployment.sh create - env: - GITHUB_TOKEN: ${{ github.token }} - DEPLOY_ENVIRONMENT: codercom-preview-docs - - - name: Deploy Preview to Vercel - id: preview - run: ./ci/scripts/deploy_vercel.sh - env: - VERCEL_ORG_ID: team_tGkWfhEGGelkkqUUm9nXq17r - VERCEL_PROJECT_ID: QmZRucMRh3GFk1817ZgXjRVuw5fhTspHPHKct3JNQDEPGd - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - CODER_DOCS_MAIN_BRANCH: ${{ github.event.pull_request.head.sha }} - - # This ensures the docs site is built properly - # as it will sometimes throw a 404 or 500 - # error if Markdown/parsing errors are present - - name: Install node_modules - run: yarn install - - name: Check docs - run: yarn ts-node ./product/coder.com/site/scripts/checkDocs.ts - env: - BASE_URL: ${{ steps.preview.outputs.url }} - - name: Update Deployment - # If we don't specify always, it won't run this check if failed. - # This means the deployment would be stuck pending. - if: always() - run: ./ci/scripts/github_deployment.sh update env: GITHUB_DEPLOYMENT: ${{ steps.deployment.outputs.id }} GITHUB_TOKEN: ${{ github.token }} - DEPLOY_STATUS: ${{ steps.preview.outcome }} - DEPLOY_URL: ${{ steps.preview.outputs.url }} + DEPLOY_STATUS: success + DEPLOY_URL: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} - name: Comment Credentials uses: marocchino/sticky-pull-request-comment@v2 - if: always() with: header: codercom-preview-docs message: | ✨ Coder.com for PR #${{ github.event.number }} deployed! It will be updated on every commit. - * _Host_: ${{ steps.preview.outputs.url }}/docs - * _Last deploy status_: ${{ steps.preview.outcome }} + * _Host_: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} + * _Last deploy status_: success * _Commit_: ${{ github.event.pull_request.head.sha }} * _Workflow status_: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} From 1392498f85e5b434e7df93fcaa0ce34812520e29 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:39:30 +0000 Subject: [PATCH 2/8] Fix update deployment --- .github/workflows/preview.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index a7a071ee6..108800534 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update Deployment + run: ./ci/scripts/github_deployment.sh update env: GITHUB_DEPLOYMENT: ${{ steps.deployment.outputs.id }} GITHUB_TOKEN: ${{ github.token }} From d095184105afcedcc190491e5fc3f3504dc31f94 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:42:36 +0000 Subject: [PATCH 3/8] Do checkout --- .github/workflows/preview.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 108800534..b059600a2 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -11,6 +11,11 @@ jobs: name: Preview runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_ACCESS_TOKEN }} + - name: Update Deployment run: ./ci/scripts/github_deployment.sh update env: From cee1361aafa14279c76fd75024fe4fc030eef15f Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:44:39 +0000 Subject: [PATCH 4/8] Fix update deployment --- .github/workflows/preview.yaml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index b059600a2..20d2f2eb3 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -11,18 +11,13 @@ jobs: name: Preview runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment with: - token: ${{ secrets.GH_ACCESS_TOKEN }} - - - name: Update Deployment - run: ./ci/scripts/github_deployment.sh update - env: - GITHUB_DEPLOYMENT: ${{ steps.deployment.outputs.id }} - GITHUB_TOKEN: ${{ github.token }} - DEPLOY_STATUS: success - DEPLOY_URL: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} + token: "${{ github.token }}" + target_url: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} + environment: preview - name: Comment Credentials uses: marocchino/sticky-pull-request-comment@v2 From 5253929520e93ee51651b7d7db98b59532b358c7 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:46:53 +0000 Subject: [PATCH 5/8] Checkout code --- .github/workflows/preview.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 20d2f2eb3..156f989f3 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -11,6 +11,8 @@ jobs: name: Preview runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 + - uses: chrnorm/deployment-action@releases/v1 name: Create GitHub deployment id: deployment From 486f372dff70fbb9dc848ccecc32fd71cb654a02 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:48:11 +0000 Subject: [PATCH 6/8] Remove deployment --- .github/workflows/preview.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 156f989f3..dd3dbb380 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -12,14 +12,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - - uses: chrnorm/deployment-action@releases/v1 - name: Create GitHub deployment - id: deployment - with: - token: "${{ github.token }}" - target_url: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} - environment: preview - name: Comment Credentials uses: marocchino/sticky-pull-request-comment@v2 From 7d01b2de7b8a5edc7eca98585153a2ed864cbedf Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:55:46 +0000 Subject: [PATCH 7/8] Add permissions back --- .github/workflows/preview.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index dd3dbb380..1786e4f6d 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -6,6 +6,18 @@ on: - main - "release-*" +permissions: + actions: none + checks: none + contents: read + deployments: none + issues: none + packages: none + pull-requests: write + repository-projects: none + security-events: none + statuses: none + jobs: preview: name: Preview From 1297d4d1ca83146e0004babb6e2ac381c1449fa0 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 8 Mar 2022 19:58:32 +0000 Subject: [PATCH 8/8] Use sha_short --- .github/workflows/preview.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 1786e4f6d..11bfa1739 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -25,6 +25,10 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Set outputs + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Comment Credentials uses: marocchino/sticky-pull-request-comment@v2 with: @@ -32,7 +36,7 @@ jobs: message: | ✨ Coder.com for PR #${{ github.event.number }} deployed! It will be updated on every commit. - * _Host_: https://coder.com/docs/coder/${{ github.event.pull_request.head.sha }} + * _Host_: https://coder.com/docs/coder/${{ steps.vars.outputs.sha_short }} * _Last deploy status_: success * _Commit_: ${{ github.event.pull_request.head.sha }} * _Workflow status_: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}