2022-01-25 15:10:34 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
name: Frontend / Deploy PR to Netlify
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
on:
|
2022-11-06 19:07:44 +00:00
|
|
|
pull_request:
|
2022-11-11 09:55:08 +00:00
|
|
|
branches: [ develop ]
|
2022-11-06 19:07:44 +00:00
|
|
|
types:
|
|
|
|
- labeled
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
- reopened
|
|
|
|
- ready_for_review
|
2022-10-21 16:57:29 +00:00
|
|
|
pull_request_target:
|
2022-11-11 09:55:08 +00:00
|
|
|
branches: [ develop ]
|
2022-10-21 16:57:29 +00:00
|
|
|
types:
|
|
|
|
- labeled
|
|
|
|
- opened
|
|
|
|
- synchronize
|
|
|
|
- reopened
|
|
|
|
- ready_for_review
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
deployments: write
|
|
|
|
|
|
|
|
env:
|
|
|
|
NETLIFY_VERSION: 12.0.11
|
2022-12-11 23:46:30 +00:00
|
|
|
NODEJS_VERSION: 18
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 17:40:59 +00:00
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label }}-${{ github.event_name }}-${{ github.job }}
|
2022-11-11 09:55:08 +00:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-01-25 15:10:34 +00:00
|
|
|
jobs:
|
|
|
|
deploy:
|
2023-02-07 18:19:56 +00:00
|
|
|
if: "contains(github.event.pull_request.labels.*.name, 'ci: force deployment') && ((github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork)"
|
2022-01-25 15:10:34 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Deploys to netlify
|
2022-10-21 16:57:29 +00:00
|
|
|
env:
|
|
|
|
DEPLOY_URL: "https://${{ github.event.number }}--hedgedoc-ui-test.netlify.app/"
|
2022-01-25 15:10:34 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-01-08 22:11:23 +00:00
|
|
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-06 21:04:23 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-11-29 16:36:57 +00:00
|
|
|
- name: Setup node
|
|
|
|
uses: ./.github/actions/setup-node
|
2022-01-25 15:10:34 +00:00
|
|
|
with:
|
2022-12-11 23:46:30 +00:00
|
|
|
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
|
2022-10-21 16:57:29 +00:00
|
|
|
|
|
|
|
- name: Patch intro.md to include netlify banner.
|
|
|
|
run: cp netlify/intro.md public/public/intro.md
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-10-21 16:57:29 +00:00
|
|
|
- name: Patch motd.md to include privacy policy.
|
|
|
|
run: cp netlify/motd.md public/public/motd.md
|
|
|
|
|
|
|
|
- name: Patch version.json to include git hash
|
|
|
|
run: jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json && mv src/_version.json src/version.json
|
|
|
|
|
|
|
|
- name: Patch base URL
|
2023-02-05 08:31:33 +00:00
|
|
|
run: echo "HD_BASE_URL=\"${{ env.DEPLOY_URL }}\"" >> .env.production
|
2022-07-30 22:39:49 +00:00
|
|
|
|
2022-09-18 18:12:51 +00:00
|
|
|
- name: Build app
|
2022-12-11 23:46:30 +00:00
|
|
|
run: yarn turbo run build --filter=frontend
|
|
|
|
shell: bash
|
|
|
|
working-directory: .
|
|
|
|
env:
|
|
|
|
NEXT_PUBLIC_USE_MOCK_API: true
|
|
|
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
|
|
TURBO_API: ${{ vars.TURBO_API }}
|
|
|
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- name: Remove Next.js cache to avoid it being deployed
|
|
|
|
run: rm -r .next/cache
|
|
|
|
|
|
|
|
- name: Mark GitHub deployment as started
|
2023-01-21 23:54:28 +00:00
|
|
|
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3 # v1.4.0
|
2022-01-25 15:10:34 +00:00
|
|
|
id: github-deployment
|
|
|
|
with:
|
|
|
|
step: start
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2022-01-27 16:55:01 +00:00
|
|
|
env: "PR #${{ github.event.number }}"
|
2022-02-27 17:26:59 +00:00
|
|
|
override: true
|
2022-01-25 15:10:34 +00:00
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
|
2022-10-21 16:57:29 +00:00
|
|
|
- name: Install netlify CLI
|
|
|
|
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
|
|
|
|
|
|
|
|
- name: Run netlify CLI
|
2022-01-25 15:10:34 +00:00
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
2022-10-21 16:57:29 +00:00
|
|
|
run: "netlify deploy --build --context deploy-preview --alias \"${{ github.event.number }}\" --json --message \"PR #${{ github.event.number }}\""
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- name: Mark GitHub deployment as finished
|
2023-01-21 23:54:28 +00:00
|
|
|
uses: bobheadxi/deployments@88ce5600046c82542f8246ac287d0a53c461bca3 # v1.4.0
|
2022-01-25 15:10:34 +00:00
|
|
|
with:
|
|
|
|
step: finish
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2022-10-21 16:57:29 +00:00
|
|
|
env_url: ${{ env.DEPLOY_URL }}
|
2022-02-27 18:08:35 +00:00
|
|
|
env: ${{ steps.github-deployment.outputs.env }}
|
2022-01-25 15:10:34 +00:00
|
|
|
status: ${{ job.status }}
|
|
|
|
deployment_id: ${{ steps.github-deployment.outputs.deployment_id }}
|
2022-02-27 17:26:59 +00:00
|
|
|
override: true
|