forked from farmOS/farmOS-community-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add configuration for netlify deploy previews
- Loading branch information
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
farmOS.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[build] | ||
publish = "farmOS.org/public/" | ||
command = "npm run build-preview" | ||
|
||
[[headers]] | ||
for = "/*" | ||
[headers.values] | ||
X-Robots-Tag = "noindex" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import fetch from 'node-fetch' | ||
|
||
const getPullRequestRepoUrl = async () => { | ||
if (process.env.PULL_REQUEST) { | ||
const repoUrl = process.env.REPOSITORY_URL | ||
const repoName = repoUrl.replace("https://github.com/", "") | ||
const branch = process.env.BRANCH | ||
const pullRequest = branch.replace("pull/", "").replace("/head", "") | ||
const response = await fetch(`https://api.github.com/repos/${repoName}/pulls/${pullRequest}`) | ||
const prInfo = await response.json() | ||
console.log(prInfo.head.repo.clone_url) | ||
return | ||
} | ||
console.log(process.env.HEAD) | ||
} | ||
getPullRequestRepoUrl() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"private": true, | ||
"name": "farmos-community-blog", | ||
"type": "module", | ||
"scripts": { | ||
"build-preview": "rm -rf farmOS.org && git clone --depth=1 https://github.com/farmOS/farmOS.org && cd farmOS.org && npm i && BLOG_REPO=$(node ../netlifyGetRepoUrl.js) BLOG_REPO_BRANCH=$HEAD npm run build" | ||
}, | ||
"devDependencies": { | ||
"node-fetch": "^3.3.0" | ||
} | ||
} |