Skip to content

Commit 3c59eab

Browse files
authoredMay 6, 2020
docs: basic auth example (#46)
* docs: basic auth example example of Basic Authentication
1 parent e101d85 commit 3c59eab

File tree

8 files changed

+488
-2
lines changed

8 files changed

+488
-2
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: example - basic auth
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
basic-auth:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: ./
16+
id: now-deployment-staging
17+
if: github.event_name == 'pull_request'
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
zeit-token: ${{ secrets.ZEIT_TOKEN }}
21+
now-org-id: ${{ secrets.NOW_ORG_ID }}
22+
now-project-id: ${{ secrets.NOW_PROJECT_ID_AUTH }}
23+
working-directory: example/express-basic-auth
24+
- uses: ./
25+
id: now-deployment-production
26+
if: github.event_name == 'push'
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
zeit-token: ${{ secrets.ZEIT_TOKEN }}
30+
now-org-id: ${{ secrets.NOW_ORG_ID }}
31+
now-project-id: ${{ secrets.NOW_PROJECT_ID_AUTH }}
32+
now-args: '--prod'
33+
working-directory: example/express-basic-auth

‎README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ This action make a ZEIT Now deployment with github actions.
3535

3636
The url of deployment preview.
3737

38+
### `preview-name`
39+
40+
The name of deployment name.
41+
3842
## Example Usage
3943

4044
### Disable ZEIT Now for GitHub
@@ -68,7 +72,6 @@ When set to false, `ZEIT Now for GitHub` will not deploy the given project regar
6872
`now.json` Example:
6973
```json
7074
{
71-
"name": "zeit-now-deployment",
7275
"version": 2,
7376
"scope": "amond",
7477
"public": false,
@@ -137,6 +140,15 @@ jobs:
137140
```
138141
139142
140-
### Agnular Example
143+
### Angular Example
141144
142145
See [.github/workflow/example-angular.yml](/.github/workflows/example-angular.yml) ,
146+
147+
148+
### Basic Auth Example
149+
150+
How to add Basic Authentication to a Now deployment
151+
152+
See [.github/workflow/examole-express-basic-auth.yml](.github/workflow/examole-express-basic-auth.yml)
153+
154+
[https://github.com/amondnet/now-deployment/tree/master/example/angular](Source Code)

‎example/express-basic-auth/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.now
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Working
2+
Static

‎example/express-basic-auth/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const express = require("express");
2+
const basicAuth = require("express-basic-auth");
3+
4+
const app = express();
5+
6+
app.use(
7+
basicAuth({
8+
users: {
9+
user: "pass"
10+
},
11+
challenge: true
12+
})
13+
);
14+
app.use(express.static(__dirname + '/_static'));
15+
16+
app.listen(4444, () => console.log('Listening on port 4444...'));

‎example/express-basic-auth/now.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 2,
3+
"public": false,
4+
"builds": [
5+
{
6+
"src": "index.js",
7+
"use": "@now/node-server",
8+
"config": {
9+
"includeFiles": ["_static/**/*.js"]
10+
}
11+
}
12+
],
13+
"routes": [
14+
{ "src": "/(.*)", "dest": "index.js" }
15+
]
16+
}

0 commit comments

Comments
 (0)