Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: now cli v17, add NOW_PROJECT_ID and NOW_ORG_ID env variable #26

Merged
merged 15 commits into from
Feb 18, 2020
Prev Previous commit
Next Next commit
feat: now cli v17
amondnet committed Feb 18, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
amondnet Minsu Lee
commit 93043e840ab650fb9f09e44ed6d23333d7698c12
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -15,4 +15,5 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
zeit-token: ${{ secrets.ZEIT_TOKEN }}
github-comment: false
#ZEIT_TEAMID: amond
now-org-id: ${{ secrets.NOW_ORG_ID }}
now-project-id: $$ {{ secrets.NOW_PROJECT_ID_STATIC }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#node_modules
.idea

.now
52 changes: 20 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -18,25 +18,17 @@ This action make a ZEIT Now deployment with github actions.
[commit](https://github.com/amondnet/now-deployment/commit/3d926623510294463c589327f5420663b1b0b35f)
## Inputs

### `zeit-token`
| Name | Required | Default | Description |
|-------------------|:--------:|---------|---------------------------------------------------------------------------------------------------|
| zeit-token | [x] | | ZEIT now token. |
| zeit-team-id | [ ] | | if your deployment is made on team project and `github-comment` is true. example: `team_asdf1234` |
| github-comment | [ ] | true | if you don't want to comment on pull request. |
| github-token | [ ] | | if you want to comment on pull request. |
| now-args | [ ] | | This is optional args for `now` cli. Example: `--prod` |
| working-directory | [ ] | | the working directory |
| now-project-id | [x] | | ❗️Now CLI 17+,The `name` property in now.json is deprecated (https://zeit.ink/5F) |
| now-org-id | [x] | | ❗️Now CLI 17+,The `name` property in now.json is deprecated (https://zeit.ink/5F) |

**required** ZEIT now token.

### `zeit-team-id`

**optional** This is required if your deployment is made on team project and `github-comment` is true. example: `team_asdf1234`

### `github-comment`

**optional** This is required if you don't want to comment on pull request. default: true

### `github-token`

**optional** This is required if you want to comment on pull request.

### `now-args`

**optional** This is optional args for `now` cli. Example: `--prod`

## Outputs

@@ -46,6 +38,12 @@ The url of deployment preview.

## Example Usage

`now.json`
```
github.enabled: false
```
When set to false, ZEIT Now for GitHub will not deploy the given project regardless of the GitHub app being installed.

```json
{
"name": "zeit-now-deployment",
@@ -79,18 +77,8 @@ jobs:
zeit-token: ${{ secrets.ZEIT_TOKEN }} # Required
github-token: ${{ secrets.GITHUB_TOKEN }} #Optional
zeit-team-id: team_XXXXXXXXXXX #Optional
now-args: '--prod' #Optional
now-args: '--prod' #Optional
now-org-id: 'YOUR_ORG' #Required
now-project-id: 'YOUR_PROJECT_ID' #Required
working-directory: ./sub-directory
```
## specific working-directory
```yml
- uses: amondnet/now-deployment@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
zeit-token: ${{ secrets.ZEIT_TOKEN }}
zeit-team-id: team_XXXXXXXXXXX
now-args: '--prod'
working-directory: ./sub-directory
```
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ inputs:
working-directory:
required: false
description: the working directory
now-project-id:
required: false
description: 'Now CLI 17+, ❗️ The `name` property in now.json is deprecated (https://zeit.ink/5F)'
now-org-id:
required: false
description: 'Now CLI 17+, ❗️ The `name` property in now.json is deprecated (https://zeit.ink/5F)'


outputs:
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ const githubToken = core.getInput('github-token')
const githubComment = core.getInput('github-comment') === 'true'
const githubDeployment = core.getInput('github-deployment') === 'true'
const workingDirectory = core.getInput('working-directory')
const nowOrgId = core.getInput('now-org-id')
const nowProjectId = core.getInput('now-project-id')

const zeitAPIClient = axios.create({
baseURL: 'https://api.zeit.co', headers: {
@@ -29,6 +31,7 @@ if ( githubToken ) {
}

async function run () {
await setEnv()
await nowDeploy()
if ( githubComment && githubToken ) {
if (context.issue.number) {
@@ -43,6 +46,18 @@ async function run () {
}
}

async function setEnv() {
core.info('set environment for now cli 17+')
if ( nowOrgId ) {
core.info('set env variable : NOW_ORG_ID')
core.exportVariable('NOW_ORG_ID', nowOrgId )
}
if ( nowProjectId ) {
core.info('set env variable : NOW_PROJECT_ID')
core.exportVariable('NOW_PROJECT_ID', nowProjectId)
}
}

async function nowDeploy () {
const commit = execSync('git log -1 --pretty=format:%B').toString().trim()

@@ -65,6 +80,7 @@ async function nowDeploy () {
return await exec.exec('npx', [
'now',
...(nowArgs.split(/ +/)),
'--confirm',
'-t',
zeitToken,
'-m',