Compare commits

...

4 Commits

Author SHA1 Message Date
f094b77505 fix: avoid issue with case sensitivity of repo names (#1179)
* fix: avoid issue with case sensitivity in condition

* chore: upgrade jest to v28
2022-05-08 17:37:36 +09:00
af7c021bb9 docs: shorten quote 2022-04-22 14:27:14 +09:00
97872c4843 docs: update GA quote/ref in concepts-guidelines.md (#1169)
* Update GA quote/ref in concepts-guidelines.md

The current quote and reference link appear to be out of date

* Change "Triggering further workflow runs" excerpt
2022-04-14 08:39:38 +09:00
bd72e1b792 fix: use full name for head branch to allow for repo renaming (#1164) 2022-04-08 21:38:55 +09:00
6 changed files with 3945 additions and 1712 deletions

View File

@ -10,7 +10,7 @@ if [[ "$(docker images -q $IMAGE 2> /dev/null)" == "" || $ARG1 == "build" ]]; th
cat > Dockerfile << EOF cat > Dockerfile << EOF
FROM node:12-alpine FROM node:12-alpine
RUN apk --no-cache add git git-daemon RUN apk --no-cache add git git-daemon
RUN npm install jest --global RUN npm install jest jest-environment-jsdom --global
WORKDIR /cpr WORKDIR /cpr
COPY __test__/entrypoint.sh /entrypoint.sh COPY __test__/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

13
dist/index.js vendored
View File

@ -950,8 +950,11 @@ class GitHubHelper {
repo: repo repo: repo
}; };
} }
createOrUpdate(inputs, baseRepository, headBranch) { createOrUpdate(inputs, baseRepository, headRepository) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const [headOwner] = headRepository.split('/');
const headBranch = `${headOwner}:${inputs.branch}`;
const headBranchFull = `${headRepository}:${inputs.branch}`;
// Try to create the pull request // Try to create the pull request
try { try {
core.info(`Attempting creation of pull request`); core.info(`Attempting creation of pull request`);
@ -965,7 +968,7 @@ class GitHubHelper {
} }
catch (e) { catch (e) {
if (e.message && if (e.message &&
e.message.includes(`A pull request already exists for ${headBranch}`)) { e.message.includes(`A pull request already exists for`)) {
core.info(`A pull request already exists for ${headBranch}`); core.info(`A pull request already exists for ${headBranch}`);
} }
else { else {
@ -974,7 +977,7 @@ class GitHubHelper {
} }
// Update the pull request that exists for this branch and base // Update the pull request that exists for this branch and base
core.info(`Fetching existing pull request`); core.info(`Fetching existing pull request`);
const { data: pulls } = yield this.octokit.rest.pulls.list(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { state: 'open', head: headBranch, base: inputs.base })); const { data: pulls } = yield this.octokit.rest.pulls.list(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { state: 'open', head: headBranchFull, base: inputs.base }));
core.info(`Attempting update of pull request`); core.info(`Attempting update of pull request`);
const { data: pull } = yield this.octokit.rest.pulls.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pulls[0].number, title: inputs.title, body: inputs.body })); const { data: pull } = yield this.octokit.rest.pulls.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pulls[0].number, title: inputs.title, body: inputs.body }));
core.info(`Updated pull request #${pull.number} (${headBranch} => ${inputs.base})`); core.info(`Updated pull request #${pull.number} (${headBranch} => ${inputs.base})`);
@ -996,10 +999,8 @@ class GitHubHelper {
} }
createOrUpdatePullRequest(inputs, baseRepository, headRepository) { createOrUpdatePullRequest(inputs, baseRepository, headRepository) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const [headOwner] = headRepository.split('/');
const headBranch = `${headOwner}:${inputs.branch}`;
// Create or update the pull request // Create or update the pull request
const pull = yield this.createOrUpdate(inputs, baseRepository, headBranch); const pull = yield this.createOrUpdate(inputs, baseRepository, headRepository);
// Apply milestone // Apply milestone
if (inputs.milestone) { if (inputs.milestone) {
core.info(`Applying milestone '${inputs.milestone}'`); core.info(`Applying milestone '${inputs.milestone}'`);

View File

@ -136,9 +136,9 @@ For further reading regarding the security of pull requests, see this GitHub blo
Pull requests created by the action using the default `GITHUB_TOKEN` cannot trigger other workflows. If you have `on: pull_request` or `on: push` workflows acting as checks on pull requests, they will not run. Pull requests created by the action using the default `GITHUB_TOKEN` cannot trigger other workflows. If you have `on: pull_request` or `on: push` workflows acting as checks on pull requests, they will not run.
> When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. > When you use the repository's `GITHUB_TOKEN` to perform tasks, events triggered by the `GITHUB_TOKEN` will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's `GITHUB_TOKEN`, a new workflow will not run even when the repository contains a workflow configured to run when `push` events occur.
[GitHub Actions: Events that trigger workflows](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token) [GitHub Actions: Triggering a workflow from a workflow](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow)
#### Workarounds to trigger further workflow runs #### Workarounds to trigger further workflow runs

5608
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.3", "@types/jest": "^27.5.0",
"@types/node": "^16.11.11", "@types/node": "^16.11.11",
"@typescript-eslint/parser": "^5.5.0", "@typescript-eslint/parser": "^5.5.0",
"@vercel/ncc": "^0.32.0", "@vercel/ncc": "^0.32.0",
@ -46,12 +46,13 @@
"eslint-import-resolver-typescript": "^2.5.0", "eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-github": "^4.3.5", "eslint-plugin-github": "^4.3.5",
"eslint-plugin-import": "^2.25.3", "eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0", "eslint-plugin-jest": "^26.1.5",
"jest": "^27.4.3", "jest": "^28.1.0",
"jest-circus": "^27.4.2", "jest-circus": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"prettier": "^2.5.0", "prettier": "^2.5.0",
"ts-jest": "^27.0.7", "ts-jest": "^28.0.2",
"typescript": "^4.5.2" "typescript": "^4.5.2"
} }
} }

View File

@ -39,8 +39,12 @@ export class GitHubHelper {
private async createOrUpdate( private async createOrUpdate(
inputs: Inputs, inputs: Inputs,
baseRepository: string, baseRepository: string,
headBranch: string headRepository: string
): Promise<Pull> { ): Promise<Pull> {
const [headOwner] = headRepository.split('/')
const headBranch = `${headOwner}:${inputs.branch}`
const headBranchFull = `${headRepository}:${inputs.branch}`
// Try to create the pull request // Try to create the pull request
try { try {
core.info(`Attempting creation of pull request`) core.info(`Attempting creation of pull request`)
@ -63,7 +67,7 @@ export class GitHubHelper {
} catch (e: any) { } catch (e: any) {
if ( if (
e.message && e.message &&
e.message.includes(`A pull request already exists for ${headBranch}`) e.message.includes(`A pull request already exists for`)
) { ) {
core.info(`A pull request already exists for ${headBranch}`) core.info(`A pull request already exists for ${headBranch}`)
} else { } else {
@ -76,7 +80,7 @@ export class GitHubHelper {
const {data: pulls} = await this.octokit.rest.pulls.list({ const {data: pulls} = await this.octokit.rest.pulls.list({
...this.parseRepository(baseRepository), ...this.parseRepository(baseRepository),
state: 'open', state: 'open',
head: headBranch, head: headBranchFull,
base: inputs.base base: inputs.base
}) })
core.info(`Attempting update of pull request`) core.info(`Attempting update of pull request`)
@ -113,11 +117,12 @@ export class GitHubHelper {
baseRepository: string, baseRepository: string,
headRepository: string headRepository: string
): Promise<Pull> { ): Promise<Pull> {
const [headOwner] = headRepository.split('/')
const headBranch = `${headOwner}:${inputs.branch}`
// Create or update the pull request // Create or update the pull request
const pull = await this.createOrUpdate(inputs, baseRepository, headBranch) const pull = await this.createOrUpdate(
inputs,
baseRepository,
headRepository
)
// Apply milestone // Apply milestone
if (inputs.milestone) { if (inputs.milestone) {