|
| 1 | +name: Docs preview |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + actions: none |
| 10 | + checks: none |
| 11 | + contents: read |
| 12 | + deployments: none |
| 13 | + issues: none |
| 14 | + packages: none |
| 15 | + pull-requests: write |
| 16 | + repository-projects: none |
| 17 | + security-events: none |
| 18 | + statuses: none |
| 19 | + |
| 20 | +jobs: |
| 21 | + preview: |
| 22 | + name: Docs preview |
| 23 | + runs-on: ubuntu-20.04 |
| 24 | + steps: |
| 25 | + - name: Cancel Previous Runs |
| 26 | + |
| 27 | + |
| 28 | + - name: Checkout m |
| 29 | + uses: actions/checkout@v2 |
| 30 | + with: |
| 31 | + repository: cdr/m |
| 32 | + ref: refs/heads/master |
| 33 | + token: ${{ secrets.GH_ACCESS_TOKEN }} |
| 34 | + submodules: true |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Install Node.js |
| 38 | + uses: actions/setup-node@v2 |
| 39 | + with: |
| 40 | + node-version: 12.x |
| 41 | + |
| 42 | + - name: Cache Node Modules |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: "/node_modules" |
| 46 | + key: node-${{ hashFiles('yarn.lock') }} |
| 47 | + |
| 48 | + - name: Create Deployment |
| 49 | + id: deployment |
| 50 | + run: ./ci/scripts/github_deployment.sh create |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ github.token }} |
| 53 | + DEPLOY_ENVIRONMENT: codercom-preview-docs |
| 54 | + |
| 55 | + - name: Deploy Preview to Vercel |
| 56 | + id: preview |
| 57 | + run: ./ci/scripts/deploy_vercel.sh |
| 58 | + env: |
| 59 | + VERCEL_ORG_ID: team_tGkWfhEGGelkkqUUm9nXq17r |
| 60 | + VERCEL_PROJECT_ID: QmZRucMRh3GFk1817ZgXjRVuw5fhTspHPHKct3JNQDEPGd |
| 61 | + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 62 | + CODE_SERVER_DOCS_MAIN_BRANCH: ${{ github.event.pull_request.head.sha }} |
| 63 | + |
| 64 | + - name: Install node_modules |
| 65 | + run: yarn install |
| 66 | + |
| 67 | + - name: Check docs |
| 68 | + run: yarn ts-node ./product/coder.com/site/scripts/checkDocs.ts |
| 69 | + env: |
| 70 | + BASE_URL: ${{ steps.preview.outputs.url }} |
| 71 | + |
| 72 | + - name: Update Deployment |
| 73 | + # If we don't specify always, it won't run this check if failed. |
| 74 | + # This means the deployment would be stuck pending. |
| 75 | + if: always() |
| 76 | + run: ./ci/scripts/github_deployment.sh update |
| 77 | + env: |
| 78 | + GITHUB_DEPLOYMENT: ${{ steps.deployment.outputs.id }} |
| 79 | + GITHUB_TOKEN: ${{ github.token }} |
| 80 | + DEPLOY_STATUS: ${{ steps.preview.outcome }} |
| 81 | + DEPLOY_URL: ${{ steps.preview.outputs.url }} |
| 82 | + |
| 83 | + - name: Comment Credentials |
| 84 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 85 | + if: always() |
| 86 | + with: |
| 87 | + header: codercom-preview-docs |
| 88 | + message: | |
| 89 | + ✨ Coder.com for PR #${{ github.event.number }} deployed! It will be updated on every commit. |
| 90 | +
|
| 91 | + * _Host_: ${{ steps.preview.outputs.url }}/docs/code-server |
| 92 | + * _Last deploy status_: ${{ steps.preview.outcome }} |
| 93 | + * _Commit_: ${{ github.event.pull_request.head.sha }} |
| 94 | + * _Workflow status_: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
0 commit comments