From eabc941c8f5be3b107292bd11cea9f411b6e1235 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Sun, 6 Feb 2022 20:38:40 +0100 Subject: [PATCH] Add commit hash to version on netlify deployment (#1838) --- netlify.toml | 2 +- netlify/build.sh | 13 ------------- netlify/patch-files.sh | 14 ++++++++++++++ netlify/patch-intro.js | 23 ----------------------- package.json | 2 +- 5 files changed, 16 insertions(+), 38 deletions(-) delete mode 100755 netlify/build.sh create mode 100644 netlify/patch-files.sh delete mode 100644 netlify/patch-intro.js diff --git a/netlify.toml b/netlify.toml index 9ac56f627..f4661b875 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] publish = ".next" -command = "bash netlify/build.sh" +command = "echo Pseudo build command because the build is made by the CI" [[plugins]] package = "@netlify/plugin-nextjs" diff --git a/netlify/build.sh b/netlify/build.sh deleted file mode 100755 index 78ec16f6d..000000000 --- a/netlify/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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/patch-files.sh b/netlify/patch-files.sh new file mode 100644 index 000000000..63db6ca74 --- /dev/null +++ b/netlify/patch-files.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) +# +# SPDX-License-Identifier: AGPL-3.0-only + +set -e + +echo 'Patch intro.md to include netlify banner.' +cp netlify/intro.md public/mock-backend/public/intro.md +echo 'Patch motd.txt to include privacy policy.' +cp netlify/motd.txt public/mock-backend/public/motd.txt +echo 'Patch version.json to include git hash' +jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json +mv src/_version.json src/version.json diff --git a/netlify/patch-intro.js b/netlify/patch-intro.js deleted file mode 100644 index b066e8dbe..000000000 --- a/netlify/patch-intro.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -const { copyFile } = require('fs/promises'); - -console.log("Patch intro.md to include netlify banner.") -copyFile("netlify/intro.md", "public/mock-backend/public/intro.md") - .then(() => console.log("Copied intro.md")) - .catch((error) => { - console.error(error); - process.exit(1); - }) - -console.log("Patch motd.txt to include privacy policy.") -copyFile("netlify/motd.txt", "public/mock-backend/public/motd.txt") - .then(() => console.log("Copied motd.txt")) - .catch((error) => { - console.error(error); - process.exit(1); - }) diff --git a/package.json b/package.json index 2873b30b7..3f7b611f6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "AGPL-3.0", "scripts": { "build": "next build", - "build:netlify": "node netlify/patch-intro.js && cross-env NEXT_PUBLIC_IGNORE_IFRAME_ORIGIN_CONFIG=true yarn build:mock", + "build:netlify": "bash netlify/patch-files.sh && cross-env NEXT_PUBLIC_IGNORE_IFRAME_ORIGIN_CONFIG=true yarn build:mock", "build:mock": "cross-env NEXT_PUBLIC_USE_MOCK_API=true next build", "build:test": "cross-env NEXT_PUBLIC_USE_MOCK_API=true NEXT_PUBLIC_TEST_MODE=true next build", "analyze": "cross-env ANALYZE=true next build",