Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 57c20f2

Browse files
committed
input name changes
1 parent ae2abd8 commit 57c20f2

File tree

5 files changed

+41
-146
lines changed

5 files changed

+41
-146
lines changed

.github/workflows/ci.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
uses: ./
6666
with:
6767
token: ${{ secrets.COUPC_PAT }}
68-
project-name: '[CI] coupc ${{ matrix.target }}'
68+
project-title: '[CI] coupc ${{ matrix.target }}'
6969
column-name: Test column 1
7070
issue-number: 1
7171

@@ -81,14 +81,14 @@ jobs:
8181
# - name: Repo project - card exists
8282
# uses: ./
8383
# with:
84-
# project-name: '[CI] ${{ matrix.target }}'
84+
# project-title: '[CI] ${{ matrix.target }}'
8585
# column-name: Test column 1
8686
# issue-number: 1
8787

8888
# - name: Repo project - move card
8989
# uses: ./
9090
# with:
91-
# project-name: '[CI] ${{ matrix.target }}'
91+
# project-title: '[CI] ${{ matrix.target }}'
9292
# column-name: Test column 2
9393
# issue-number: 1
9494

@@ -105,15 +105,15 @@ jobs:
105105
# id: coupc-2
106106
# uses: ./
107107
# with:
108-
# project-name: '[CI] ${{ matrix.target }}'
108+
# project-title: '[CI] ${{ matrix.target }}'
109109
# column-name: Test column 1
110110
# issue-number: ${{ github.event.number }}
111111

112112
# - name: Repo project - card exists (pull request)
113113
# if: github.event_name == 'pull_request'
114114
# uses: ./
115115
# with:
116-
# project-name: '[CI] ${{ matrix.target }}'
116+
# project-title: '[CI] ${{ matrix.target }}'
117117
# column-name: Test column 1
118118
# issue-number: ${{ github.event.number }}
119119

@@ -133,8 +133,8 @@ jobs:
133133
# uses: ./
134134
# with:
135135
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
136-
# project-location: create-or-update-project-card
137-
# project-name: '[CI] ${{ matrix.target }}'
136+
# project-owner: create-or-update-project-card
137+
# project-title: '[CI] ${{ matrix.target }}'
138138
# column-name: Test column 1
139139
# repository: create-or-update-project-card/test-fixture
140140
# issue-number: 1
@@ -143,8 +143,8 @@ jobs:
143143
# uses: ./
144144
# with:
145145
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
146-
# project-location: create-or-update-project-card
147-
# project-name: '[CI] ${{ matrix.target }}'
146+
# project-owner: create-or-update-project-card
147+
# project-title: '[CI] ${{ matrix.target }}'
148148
# column-name: Test column 1
149149
# repository: create-or-update-project-card/test-fixture
150150
# issue-number: 1
@@ -153,8 +153,8 @@ jobs:
153153
# uses: ./
154154
# with:
155155
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
156-
# project-location: create-or-update-project-card
157-
# project-name: '[CI] ${{ matrix.target }}'
156+
# project-owner: create-or-update-project-card
157+
# project-title: '[CI] ${{ matrix.target }}'
158158
# column-name: Test column 2
159159
# repository: create-or-update-project-card/test-fixture
160160
# issue-number: 1
@@ -175,8 +175,8 @@ jobs:
175175
# uses: ./
176176
# with:
177177
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
178-
# project-location: test-case-machine-user
179-
# project-name: '[CI] ${{ matrix.target }}'
178+
# project-owner: test-case-machine-user
179+
# project-title: '[CI] ${{ matrix.target }}'
180180
# column-name: Test column 1
181181
# repository: test-case-machine-user/create-or-update-project-card-fixture
182182
# issue-number: 1
@@ -185,8 +185,8 @@ jobs:
185185
# uses: ./
186186
# with:
187187
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
188-
# project-location: test-case-machine-user
189-
# project-name: '[CI] ${{ matrix.target }}'
188+
# project-owner: test-case-machine-user
189+
# project-title: '[CI] ${{ matrix.target }}'
190190
# column-name: Test column 1
191191
# repository: test-case-machine-user/create-or-update-project-card-fixture
192192
# issue-number: 1
@@ -195,8 +195,8 @@ jobs:
195195
# uses: ./
196196
# with:
197197
# token: ${{ secrets.TEST_CASE_MACHINE_USER_PAT }}
198-
# project-location: test-case-machine-user
199-
# project-name: '[CI] ${{ matrix.target }}'
198+
# project-owner: test-case-machine-user
199+
# project-title: '[CI] ${{ matrix.target }}'
200200
# column-name: Test column 2
201201
# repository: test-case-machine-user/create-or-update-project-card-fixture
202202
# issue-number: 1

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A GitHub action to create or update a project card.
1212
- name: Create or Update Project Card
1313
uses: peter-evans/create-or-update-project-card@v3
1414
with:
15-
project-name: My project
15+
project-title: My project
1616
column-name: My column
1717
issue-number: 1
1818
```
@@ -26,7 +26,7 @@ If not in the specified column, the action will move the card.
2626
- name: Create or Update Project Card
2727
uses: peter-evans/create-or-update-project-card@v3
2828
with:
29-
project-name: My project
29+
project-title: My project
3030
column-name: My second column
3131
issue-number: 1
3232
```
@@ -40,8 +40,8 @@ When creating cards in an organization or user project, a `repo` and `admin:org`
4040
uses: peter-evans/create-or-update-project-card@v3
4141
with:
4242
token: ${{ secrets.PAT }}
43-
project-location: my-org
44-
project-name: My project
43+
project-owner: my-org
44+
project-title: My project
4545
column-name: My second column
4646
issue-number: 1
4747
```
@@ -59,7 +59,7 @@ jobs:
5959
- name: Create or Update Project Card
6060
uses: peter-evans/create-or-update-project-card@v3
6161
with:
62-
project-name: My project
62+
project-title: My project
6363
column-name: My column
6464
```
6565

@@ -81,7 +81,7 @@ jobs:
8181
- name: Create or Update Project Card
8282
uses: peter-evans/create-or-update-project-card@v3
8383
with:
84-
project-name: My project
84+
project-title: My project
8585
column-name: My column
8686
issue-number: ${{ github.event.number }}
8787
```
@@ -91,9 +91,9 @@ jobs:
9191
| Name | Description | Default |
9292
| --- | --- | --- |
9393
| `token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
94-
| `project-location` | The location of the project. Either a repository, organization, or user. | `github.repository` (current repository) |
95-
| `project-number` | (**semi-required**) The number of the project. Either `project-number` OR `project-name` must be supplied. | |
96-
| `project-name` | (**semi-required**) The name of the project. Either `project-number` OR `project-name` must be supplied. Note that a project's name is not unique. The action will use the first matching project found. | |
94+
| `project-owner` | The owner of the project. Either an organization, or user. | `github.repository_owner` (current repository owner) |
95+
| `project-number` | (**semi-required**) The number of the project. Either `project-number` OR `project-title` must be supplied. | |
96+
| `project-title` | (**semi-required**) The title of the project. Either `project-number` OR `project-title` must be supplied. Note that a project's title is not unique. The action will use the first matching project found. | |
9797
| `column-name` | (**required**) The name of the column to add a card to, or move an existing card to. | |
9898
| `repository` | The GitHub repository containing the issue or pull request. | `github.repository` (current repository) |
9999
| `issue-number` | The issue or pull request number to associate with the card. | `github.event.issue.number` |
@@ -107,7 +107,7 @@ The action outputs `card-id` for use in later workflow steps.
107107
id: coupc
108108
uses: peter-evans/create-or-update-project-card@v3
109109
with:
110-
project-name: My project
110+
project-title: My project
111111
column-name: My column
112112
issue-number: 1
113113
- name: Check output

action.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ inputs:
44
token:
55
description: 'GITHUB_TOKEN or a repo scoped PAT'
66
default: ${{ github.token }}
7-
project-location:
7+
project-owner:
88
description: >
9-
The location of the project. Either a repository, organization, or user.
9+
The owner of the project. Either an organization, or user.
1010
default: ${{ github.repository_owner }}
1111
project-number:
1212
description: >
1313
The number of the project.
14-
Semi-required. Either `project-number` OR `project-name` must be supplied.
15-
project-name:
14+
Semi-required. Either `project-number` OR `project-title` must be supplied.
15+
project-title:
1616
description: >
17-
The name of the project.
18-
Semi-required. Either `project-number` OR `project-name` must be supplied.
19-
Note that a project's name is not unique. The action will use the first matching project found.
17+
The title of the project.
18+
Semi-required. Either `project-number` OR `project-title` must be supplied.
19+
Note that a project's title is not unique. The action will use the first matching project found.
2020
column-name:
2121
description: 'The name of the column to add a card to, or move an existing card to.'
2222
required: true

dist/index.js

+3-54
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ function getProjectId(octokit, projectOwner, projectNumber, projectTitle) {
147147
}
148148
`;
149149
const variables = { owner: projectOwner, title: projectTitle };
150-
core.debug(`Variables: ${(0, util_1.inspect)(variables)}`);
151150
const response = yield octokit.graphql(query, variables);
152151
core.debug(`Response: ${(0, util_1.inspect)(response)}`);
153152
if (response.user.projectsV2.nodes.length > 0) {
@@ -163,47 +162,6 @@ function getProjectId(octokit, projectOwner, projectNumber, projectTitle) {
163162
}
164163
});
165164
}
166-
function getProjects(octokit, projectLocation) {
167-
return __awaiter(this, void 0, void 0, function* () {
168-
const [owner, repo] = projectLocation.split('/');
169-
const projects = yield (() => __awaiter(this, void 0, void 0, function* () {
170-
if (repo) {
171-
return yield octokit.paginate(octokit.rest.projects.listForRepo, {
172-
owner: owner,
173-
repo: repo,
174-
per_page: 100
175-
});
176-
}
177-
else if (yield isOrg(octokit, owner)) {
178-
return yield octokit.paginate(octokit.rest.projects.listForOrg, {
179-
org: owner,
180-
per_page: 100
181-
});
182-
}
183-
else {
184-
return yield octokit.paginate(octokit.rest.projects.listForUser, {
185-
username: owner,
186-
per_page: 100
187-
});
188-
}
189-
}))();
190-
core.debug(`Projects list: ${(0, util_1.inspect)(projects)}`);
191-
return projects.map(p => {
192-
return new Project(p.number, p.name, p.id);
193-
});
194-
});
195-
}
196-
function getProject(projects, projectNumber, projectName) {
197-
if (!isNaN(projectNumber) && projectNumber > 0) {
198-
return projects.find(project => project.number == projectNumber);
199-
}
200-
else if (projectName) {
201-
return projects.find(project => project.name == projectName);
202-
}
203-
else {
204-
throw 'A valid input for project-number OR project-name must be supplied.';
205-
}
206-
}
207165
function getContent(octokit, repository, issueNumber) {
208166
return __awaiter(this, void 0, void 0, function* () {
209167
const [owner, repo] = repository.split('/');
@@ -271,26 +229,17 @@ function run() {
271229
try {
272230
const inputs = {
273231
token: core.getInput('token'),
274-
projectLocation: core.getInput('project-location'),
232+
projectOwner: core.getInput('project-owner'),
275233
projectNumber: Number(core.getInput('project-number')),
276-
projectName: core.getInput('project-name'),
234+
projectTitle: core.getInput('project-title'),
277235
columnName: core.getInput('column-name'),
278236
repository: core.getInput('repository'),
279237
issueNumber: Number(core.getInput('issue-number'))
280238
};
281239
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);
282240
const octokit = github.getOctokit(inputs.token);
283-
const projectId = yield getProjectId(octokit, inputs.projectLocation, inputs.projectNumber, inputs.projectName);
241+
const projectId = yield getProjectId(octokit, inputs.projectOwner, inputs.projectNumber, inputs.projectTitle);
284242
core.debug(`Project ID: ${projectId}`);
285-
// const projects = await getProjects(octokit, inputs.projectLocation)
286-
// core.debug(`Projects: ${inspect(projects)}`)
287-
// const project = getProject(
288-
// projects,
289-
// inputs.projectNumber,
290-
// inputs.projectName
291-
// )
292-
// core.debug(`Project: ${inspect(project)}`)
293-
// if (!project) throw 'No project matching the supplied inputs found.'
294243
// const columns = await octokit.paginate(octokit.rest.projects.listColumns, {
295244
// project_id: project.id,
296245
// per_page: 100

src/main.ts

+4-58
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ async function getProjectId(
117117
}
118118
`
119119
const variables = {owner: projectOwner, title: projectTitle}
120-
core.debug(`Variables: ${inspect(variables)}`)
121120
const response = await octokit.graphql(query, variables)
122121
core.debug(`Response: ${inspect(response)}`)
123122
if (response.user.projectsV2.nodes.length > 0) {
@@ -131,48 +130,6 @@ async function getProjectId(
131130
}
132131
}
133132

134-
async function getProjects(octokit, projectLocation): Promise<Project[]> {
135-
const [owner, repo] = projectLocation.split('/')
136-
const projects = await (async () => {
137-
if (repo) {
138-
return await octokit.paginate(octokit.rest.projects.listForRepo, {
139-
owner: owner,
140-
repo: repo,
141-
per_page: 100
142-
})
143-
} else if (await isOrg(octokit, owner)) {
144-
return await octokit.paginate(octokit.rest.projects.listForOrg, {
145-
org: owner,
146-
per_page: 100
147-
})
148-
} else {
149-
return await octokit.paginate(octokit.rest.projects.listForUser, {
150-
username: owner,
151-
per_page: 100
152-
})
153-
}
154-
})()
155-
core.debug(`Projects list: ${inspect(projects)}`)
156-
157-
return projects.map(p => {
158-
return new Project(p.number, p.name, p.id)
159-
})
160-
}
161-
162-
function getProject(
163-
projects: Project[],
164-
projectNumber,
165-
projectName
166-
): Project | undefined {
167-
if (!isNaN(projectNumber) && projectNumber > 0) {
168-
return projects.find(project => project.number == projectNumber)
169-
} else if (projectName) {
170-
return projects.find(project => project.name == projectName)
171-
} else {
172-
throw 'A valid input for project-number OR project-name must be supplied.'
173-
}
174-
}
175-
176133
async function getContent(
177134
octokit,
178135
repository,
@@ -249,9 +206,9 @@ async function run(): Promise<void> {
249206
try {
250207
const inputs = {
251208
token: core.getInput('token'),
252-
projectLocation: core.getInput('project-location'),
209+
projectOwner: core.getInput('project-owner'),
253210
projectNumber: Number(core.getInput('project-number')),
254-
projectName: core.getInput('project-name'),
211+
projectTitle: core.getInput('project-title'),
255212
columnName: core.getInput('column-name'),
256213
repository: core.getInput('repository'),
257214
issueNumber: Number(core.getInput('issue-number'))
@@ -262,23 +219,12 @@ async function run(): Promise<void> {
262219

263220
const projectId = await getProjectId(
264221
octokit,
265-
inputs.projectLocation,
222+
inputs.projectOwner,
266223
inputs.projectNumber,
267-
inputs.projectName
224+
inputs.projectTitle
268225
)
269226
core.debug(`Project ID: ${projectId}`)
270227

271-
// const projects = await getProjects(octokit, inputs.projectLocation)
272-
// core.debug(`Projects: ${inspect(projects)}`)
273-
274-
// const project = getProject(
275-
// projects,
276-
// inputs.projectNumber,
277-
// inputs.projectName
278-
// )
279-
// core.debug(`Project: ${inspect(project)}`)
280-
// if (!project) throw 'No project matching the supplied inputs found.'
281-
282228
// const columns = await octokit.paginate(octokit.rest.projects.listColumns, {
283229
// project_id: project.id,
284230
// per_page: 100

0 commit comments

Comments
 (0)