From 6e1847d1e91acece13d664ccc8f9a9e89872b049 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Thu, 27 Jan 2022 17:55:01 +0100 Subject: [PATCH] deployments: Fix main branch deployment and overrides (#1801) * Use different environment per PR Signed-off-by: Erik Michelson * Fix main deployment by using CI-aware build script Signed-off-by: Erik Michelson * Use PR title and number in netlify deployment list Signed-off-by: Erik Michelson * Use exec Signed-off-by: Erik Michelson --- .github/workflows/deploy.yml | 4 ++-- netlify.toml | 2 +- netlify/build.sh | 13 +++++++++++++ netlify/deploy.sh | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 netlify/build.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8d9b52f3c..100316546 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,14 +49,14 @@ jobs: with: step: start token: ${{ secrets.GITHUB_TOKEN }} - env: Preview + env: "PR #${{ github.event.number }}" no_override: false ref: ${{ github.head_ref }} - name: Run netlify CLI deployment env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - run: bash netlify/deploy.sh "${{ github.event.number }}" "${{ github.head_ref }}" + run: bash netlify/deploy.sh "${{ github.event.number }}" "${{ github.head_ref }}" "${{ github.event.pull_request.title }}" id: netlify-result - name: Mark GitHub deployment as finished diff --git a/netlify.toml b/netlify.toml index 911bceb8f..9ac56f627 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] publish = ".next" -command = "echo 'Assuming already built and cleaned Next.js app at ./.next/'" +command = "bash netlify/build.sh" [[plugins]] package = "@netlify/plugin-nextjs" diff --git a/netlify/build.sh b/netlify/build.sh new file mode 100755 index 000000000..78ec16f6d --- /dev/null +++ b/netlify/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) +# +# SPDX-License-Identifier: AGPL-3.0-only + +if [[ -z "${GITHUB_ACTIONS}" ]]; then + echo "Running in netlify CI or manual" + exec yarn build:netlify +else + echo "Running in GitHub actions CI" + echo "Build is not necessary as already done prior to this step." +fi diff --git a/netlify/deploy.sh b/netlify/deploy.sh index dbc92c3a6..f627852d5 100755 --- a/netlify/deploy.sh +++ b/netlify/deploy.sh @@ -6,7 +6,7 @@ deployid="$1-$2" -json=$(yarn netlify deploy --build --context deploy-preview --alias "${deployid}" --json) +json=$(yarn netlify deploy --build --context deploy-preview --alias "${deployid}" --json --message "[#$1] $3") url=$(echo "${json}" | jq -r .deploy_url) logs=$(echo "${json}" | jq -r .logs)