Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

ci: add ZEIT deployment (#120)

Abdullah Attaf89e6a8c2e4e
diff --git a/apps/web/.github/workflows/deploy.yml b/apps/web/.github/workflows/deploy.yml
index 2462dcbd5..832641c91 100644
--- a/apps/web/.github/workflows/deploy.yml
+++ b/apps/web/.github/workflows/deploy.yml
@@ -3,15 +3,20 @@ on:
push:
branches:
- master
+ pull_request:
+ branches:
+ - master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
+ env:
+ GH_DEPLOY_KEY: ${{ secrets.GH_DEPLOY_KEY }}
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false
-
+
- name: Setup SSH
uses: webfactory/[email protected]
with:
@@ -22,13 +27,12 @@ jobs:
with:
node-version: 12.x
- run: npm install
- - run: npm build
-
+
- name: Build and Deploy πŸš€
- uses: JamesIves/github-pages-deploy-action@releases/v3
+ uses: amondnet/now-deployment@v2
with:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- BRANCH: gh-pages # The branch the action should deploy to.
- FOLDER: build # The folder the action should deploy.
- COMMIT_MESSAGE: "Deploying to space..."
-
+ zeit-token: ${{ secrets.ZEIT_TOKEN }}
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ now-args: "--prod"
+ now-org-id: "Wst8mhjfr4LzbjOe956M2Z4t"
+ now-project-id: "QmStgLZ26V8aowiAAdyYaFVjRDWP9T8GEUoR9iJFSSnpWJ"
diff --git a/apps/web/.gitignore b/apps/web/.gitignore
index 4d29575de..2ebc441cd 100644
--- a/apps/web/.gitignore
+++ b/apps/web/.gitignore
@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+
+.now
\ No newline at end of file
diff --git a/apps/web/package.json b/apps/web/package.json
index 9c099abd9..e9e1af0f3 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -31,6 +31,7 @@
"typescript": "^3.8.3"
},
"scripts": {
+ "preinstall": "chmod +x ./scripts/ci.sh && ./scripts/ci.sh",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
diff --git a/apps/web/scripts/ci.sh b/apps/web/scripts/ci.sh
new file mode 100755
index 000000000..1e85268e0
--- /dev/null
+++ b/apps/web/scripts/ci.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# This script is meant to be triggered on "package.json:scripts:preinstall"
+# Once executed, it will allow fetching a private Github repository (the GITHUB_SSH_KEY_CDE is a RSA private key, that matches a Github "Deploy key")
+# See https://spectrum.chat/zeit/now/deploy-with-private-github-dependency~67f5de5b-ad7f-4ff0-afbe-c1b717cca4db
+
+echo "Resolving deployment's origin (Zeit, GitHub Actions, AWS CodeBuild), with HOME='$HOME'"
+
+function configure_ssh() {
+ echo "Configuring environment with a custom ssh key to be able to fetch private dependencies..."
+
+ local SSH_HOME="$1"/.ssh
+ echo "Using SSH_HOME='$SSH_HOME'"
+
+ mkdir -p "$SSH_HOME"
+
+ echo "${GH_DEPLOY_KEY}" >"$SSH_HOME"/id_rsa # We must use "id_rsa" file name, using a custom name will fail
+ chmod 400 "$SSH_HOME"/id_rsa
+
+ ssh-keyscan -t rsa github.com >>"$SSH_HOME"/known_hosts # Look and make trust communications between github.com and the builder
+}
+
+if [[ "$HOME" == "/zeit" ]]; then # On Zeit
+ echo "Detected environment: Zeit"
+ configure_ssh /root
+
+elif [[ "$HOME" == "/home/runner" ]]; then # On Github Actions
+ echo "Detected environment: Github Actions"
+ configure_ssh "$HOME"
+
+else
+ echo "Detected environment: None"
+ echo "This environment isn't handled (not a CI/CD env), nothing will be installed"
+fi
\ No newline at end of file