Skip to content

Commit

Permalink
fix: vercel inspect fails in team scope (amondnet#5)
Browse files Browse the repository at this point in the history
* fix: vercel inspect failed when using team scope
  • Loading branch information
amondnet authored May 18, 2020
1 parent d5a6510 commit b0d780b
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 16 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/example-scope.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: example - team scope
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
id: now-deployment-staging
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID_TEAM_SCOPE }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TEAM_SCOPE }}
working-directory: example/team-scope
scope: ${{ secrets.VERCEL_SCOPE }}
- uses: ./
id: now-deployment-production
if: github.event_name == 'push'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID_TEAM_SCOPE }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_TEAM_SCOPE }}
vercel-args: '--prod'
scope: ${{ secrets.VERCEL_SCOPE }}
working-directory: example/team-scope
2 changes: 1 addition & 1 deletion .github/workflows/example-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID_STATIC }}
now-args: '--prod'
vercel-args: '--prod'
working-directory: example/static
8 changes: 8 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
npm run package
```

# Release

```bash
git add dist
git tag --new-release
```


# Changelog

```bash
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ This action make a Vercel deployment with github actions.

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

| vercel-project-id | [x] | | ❗Vercel CLI 17+,The `name` property in vercel.json is deprecated (https://zeit.ink/5F) |
| vercel-org-id | [x] | | ❗Vercel CLI 17+,The `name` property in vercel.json is deprecated (https://zeit.ink/5F) |
| scope | [ ] | | If you are working in a team scope, you should set this value to your `team ID`.

## Outputs

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
vercel-org-id:
required: false
description: 'Vercel CLI 17+, ❗️ The `name` property in vercel.json is deprecated (https://zeit.ink/5F)'
scope:
required: false
description: 'If you are work in team scope, you should set this value to your team id.'
zeit-token:
description: 'zeit.co token'
required: true
Expand Down
12 changes: 7 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ const vercelToken = core.getInput('vercel-token', { required: true });
const vercelArgs = core.getInput('vercel-args');
const vercelOrgId = core.getInput('vercel-org-id');
const vercelProjectId = core.getInput('vercel-project-id');
const vercelScope = core.getInput('scope');

let octokit;
if (githubToken) {
Expand Down Expand Up @@ -1140,11 +1141,12 @@ async function vercelInspect(deploymentUrl) {
options.cwd = workingDirectory;
}

await exec.exec(
'npx',
['vercel', 'inspect', deploymentUrl, '-t', vercelToken],
options,
);
const args = ['vercel', 'inspect', deploymentUrl, '-t', vercelToken];
if (vercelScope) {
core.info('using scope');
args.push('--scope', vercelScope);
}
await exec.exec('npx', args, options);

const match = myError.match(/^\s+name\s+(.+)$/m);
return match && match.length ? match[1] : null;
Expand Down
1 change: 1 addition & 0 deletions example/team-scope/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
2 changes: 2 additions & 0 deletions example/team-scope/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Working
Static
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const vercelToken = core.getInput('vercel-token', { required: true });
const vercelArgs = core.getInput('vercel-args');
const vercelOrgId = core.getInput('vercel-org-id');
const vercelProjectId = core.getInput('vercel-project-id');
const vercelScope = core.getInput('scope');

let octokit;
if (githubToken) {
Expand Down Expand Up @@ -105,11 +106,12 @@ async function vercelInspect(deploymentUrl) {
options.cwd = workingDirectory;
}

await exec.exec(
'npx',
['vercel', 'inspect', deploymentUrl, '-t', vercelToken],
options,
);
const args = ['vercel', 'inspect', deploymentUrl, '-t', vercelToken];
if (vercelScope) {
core.info('using scope');
args.push('--scope', vercelScope);
}
await exec.exec('npx', args, options);

const match = myError.match(/^\s+name\s+(.+)$/m);
return match && match.length ? match[1] : null;
Expand Down

0 comments on commit b0d780b

Please sign in to comment.