Skip to content

Commit 297e9de

Browse files
committed
add branch support
1 parent a69dcee commit 297e9de

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,22 @@ This project contains a [https://yarnpkg.com/](Yarn) lock file which is a faster
2626
## Installation
2727
Install as a normal Node.js application. Add the required [configuration](#configuration) values via environment variables or similar mechanism. Or deploy to Heroku:
2828

29-
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/voxpelli/webpage-micropub-to-github)
29+
[![Deploy heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/voxpelli/webpage-micropub-to-github)
30+
31+
### Deploy to now
32+
33+
1. Install [now cli](https://zeit.co/download).
34+
2. Edit `now.json` to have right values relevant for your project.
35+
Especially make sure to change the `alias` to something unique.
36+
3. Run `now secret add micropub-github-token <yourtoken>` to setup secret.
37+
4. Run `now` to do deployment to now.
38+
5. Run `now alias`
39+
40+
This will setup a url endpoint i.e. `https://mysite-micropub.now.sh/micropub/main`
41+
you can then use in your site.
42+
43+
Note: this uses version1 of now that is based on full Docker. You'll
44+
get warnings about this but it is okey - things still works.
3045

3146
## Endpoint discovery
3247
Once deployed, your Micropub endpoint can be found at `/micropub/main` e.g. `https://example.com/micropub/main`.

lib/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const config = {
2828
port: env.PORT || 8080,
2929
host: env[prefix + 'HOST'],
3030
github: {
31-
user: env[prefix + 'GITHUB_USER'],
32-
token: env[prefix + 'GITHUB_TOKEN']
31+
user: env[prefix + 'GITHUB_USER'],
32+
token: env[prefix + 'GITHUB_TOKEN'],
33+
branch: env[prefix + 'GITHUB_BRANCH']
3334
},
3435
site: {
3536
url: env[prefix + 'SITE_URL'],

lib/handler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const matchPropertiesToConditions = function (conditions, properties) {
3131

3232
module.exports = function (githubTarget, micropubDocument, siteUrl, options) {
3333
options = removeEmptyValues(options || {}, ['layoutName']);
34+
console.log("publishing to repo: %s branch: %s", githubTarget.repo, githubTarget.branch)
3435

3536
const publisher = new GitHubPublisher(githubTarget.token, githubTarget.user, githubTarget.repo, githubTarget.branch);
3637

now.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"MICROPUB_TOKEN_ME": "https://xam.dk",
1010
"MICROPUB_GITHUB_TOKEN": "@micropub-github-token",
1111
"MICROPUB_GITHUB_USER": "maxandersen",
12+
"MICROPUB_GITHUB_BRANCH": "micropub",
1213
"MICROPUB_SITE_GITHUB_REPO": "xam.dk",
1314
"MICROPUB_SITE_URL": "https://xam.dk",
1415
"MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"",

0 commit comments

Comments
 (0)