mirror of
https://github.com/valitydev/repo-file-sync-action.git
synced 2024-11-06 01:45:19 +00:00
💬 Change commit message and PR message
This commit is contained in:
parent
e7eb3dd259
commit
43bc4e9ba7
@ -13,7 +13,7 @@ inputs:
|
||||
required: false
|
||||
PR_LABELS:
|
||||
description: |
|
||||
Labels which will be added to the pull request. Defaults to resync. Set to false to turn off
|
||||
Labels which will be added to the pull request. Defaults to sync. Set to false to turn off
|
||||
required: false
|
||||
ASSIGNEES:
|
||||
description: |
|
||||
|
31
dist/index.js
vendored
31
dist/index.js
vendored
@ -30212,7 +30212,7 @@ const context = {
|
||||
}),
|
||||
PR_LABELS: getVar({
|
||||
key: 'PR_LABELS',
|
||||
default: [ 'resync' ],
|
||||
default: [ 'sync' ],
|
||||
required: false,
|
||||
array: true
|
||||
}),
|
||||
@ -30424,8 +30424,8 @@ const init = (repo) => {
|
||||
return parse(statusOutput).length !== 0
|
||||
}
|
||||
|
||||
const commit = async (dest, source) => {
|
||||
const message = dest !== undefined ? `${ COMMIT_PREFIX } Resynced '${ dest }' with '${ GITHUB_REPOSITORY }/${ source }'` : `${ COMMIT_PREFIX } Resynced file(s) with ${ GITHUB_REPOSITORY }`
|
||||
const commit = async (msg) => {
|
||||
const message = msg !== undefined ? msg : `${ COMMIT_PREFIX } Synced file(s) with ${ GITHUB_REPOSITORY }`
|
||||
return execCmd(
|
||||
`git commit -m "${ message }"`,
|
||||
localPath
|
||||
@ -30613,10 +30613,22 @@ const run = async () => {
|
||||
}
|
||||
|
||||
core.info(`Creating commit for file ${ file.dest }`)
|
||||
await git.commit(file.dest, file.source)
|
||||
|
||||
let message
|
||||
let prMessage
|
||||
if (destExists) {
|
||||
message = `${ COMMIT_PREFIX } Synced local '${ file.dest }' with remote '${ file.source }'`
|
||||
prMessage = `Synced local <code>${ file.dest }</code> with remote <code>${ file.source }</code>`
|
||||
} else {
|
||||
message = `${ COMMIT_PREFIX } Created local '${ file.dest }' from remote '${ file.source }'`
|
||||
prMessage = `Created local <code>${ file.dest }</code> from remote <code>${ file.source }</code>`
|
||||
}
|
||||
|
||||
await git.commit(message)
|
||||
modified.push({
|
||||
dest: file.dest,
|
||||
source: file.source
|
||||
source: file.source,
|
||||
message: prMessage
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -30656,12 +30668,12 @@ const run = async () => {
|
||||
|
||||
if (COMMIT_EACH_FILE === true) {
|
||||
modified.forEach((file) => {
|
||||
list += `<li><code>${ file.dest }</code> with <code>${ file.source }</code></li>`
|
||||
list += `<li>${ file.message }</li>`
|
||||
})
|
||||
|
||||
changedFiles = dedent(`
|
||||
<details>
|
||||
<summary>Synced files</summary>
|
||||
<summary>Changed files</summary>
|
||||
<ul>
|
||||
${ list }
|
||||
</ul>
|
||||
@ -30669,14 +30681,13 @@ const run = async () => {
|
||||
`)
|
||||
}
|
||||
|
||||
|
||||
core.info(`Creating new PR`)
|
||||
const { data } = await client.pulls.create({
|
||||
owner: item.repo.user,
|
||||
repo: item.repo.name,
|
||||
title: `${ COMMIT_PREFIX } Resynced file(s) with ${ GITHUB_REPOSITORY }`,
|
||||
title: `${ COMMIT_PREFIX } Synced file(s) with ${ GITHUB_REPOSITORY }`,
|
||||
body: dedent(`
|
||||
Resynced file(s) with [${ GITHUB_REPOSITORY }](https://github.com/${ GITHUB_REPOSITORY }).
|
||||
Synced file(s) with [${ GITHUB_REPOSITORY }](https://github.com/${ GITHUB_REPOSITORY }).
|
||||
|
||||
${ changedFiles }
|
||||
|
||||
|
@ -52,7 +52,7 @@ const context = {
|
||||
}),
|
||||
PR_LABELS: getVar({
|
||||
key: 'PR_LABELS',
|
||||
default: [ 'resync' ],
|
||||
default: [ 'sync' ],
|
||||
required: false,
|
||||
array: true
|
||||
}),
|
||||
|
@ -83,8 +83,8 @@ const init = (repo) => {
|
||||
return parse(statusOutput).length !== 0
|
||||
}
|
||||
|
||||
const commit = async (dest, source) => {
|
||||
const message = dest !== undefined ? `${ COMMIT_PREFIX } Resynced '${ dest }' with '${ GITHUB_REPOSITORY }/${ source }'` : `${ COMMIT_PREFIX } Resynced file(s) with ${ GITHUB_REPOSITORY }`
|
||||
const commit = async (msg) => {
|
||||
const message = msg !== undefined ? msg : `${ COMMIT_PREFIX } Synced file(s) with ${ GITHUB_REPOSITORY }`
|
||||
return execCmd(
|
||||
`git commit -m "${ message }"`,
|
||||
localPath
|
||||
|
25
src/index.js
25
src/index.js
@ -82,10 +82,22 @@ const run = async () => {
|
||||
}
|
||||
|
||||
core.info(`Creating commit for file ${ file.dest }`)
|
||||
await git.commit(file.dest, file.source)
|
||||
|
||||
let message
|
||||
let prMessage
|
||||
if (destExists) {
|
||||
message = `${ COMMIT_PREFIX } Synced local '${ file.dest }' with remote '${ file.source }'`
|
||||
prMessage = `Synced local <code>${ file.dest }</code> with remote <code>${ file.source }</code>`
|
||||
} else {
|
||||
message = `${ COMMIT_PREFIX } Created local '${ file.dest }' from remote '${ file.source }'`
|
||||
prMessage = `Created local <code>${ file.dest }</code> from remote <code>${ file.source }</code>`
|
||||
}
|
||||
|
||||
await git.commit(message)
|
||||
modified.push({
|
||||
dest: file.dest,
|
||||
source: file.source
|
||||
source: file.source,
|
||||
message: prMessage
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -125,12 +137,12 @@ const run = async () => {
|
||||
|
||||
if (COMMIT_EACH_FILE === true) {
|
||||
modified.forEach((file) => {
|
||||
list += `<li><code>${ file.dest }</code> with <code>${ file.source }</code></li>`
|
||||
list += `<li>${ file.message }</li>`
|
||||
})
|
||||
|
||||
changedFiles = dedent(`
|
||||
<details>
|
||||
<summary>Synced files</summary>
|
||||
<summary>Changed files</summary>
|
||||
<ul>
|
||||
${ list }
|
||||
</ul>
|
||||
@ -138,14 +150,13 @@ const run = async () => {
|
||||
`)
|
||||
}
|
||||
|
||||
|
||||
core.info(`Creating new PR`)
|
||||
const { data } = await client.pulls.create({
|
||||
owner: item.repo.user,
|
||||
repo: item.repo.name,
|
||||
title: `${ COMMIT_PREFIX } Resynced file(s) with ${ GITHUB_REPOSITORY }`,
|
||||
title: `${ COMMIT_PREFIX } Synced file(s) with ${ GITHUB_REPOSITORY }`,
|
||||
body: dedent(`
|
||||
Resynced file(s) with [${ GITHUB_REPOSITORY }](https://github.com/${ GITHUB_REPOSITORY }).
|
||||
Synced file(s) with [${ GITHUB_REPOSITORY }](https://github.com/${ GITHUB_REPOSITORY }).
|
||||
|
||||
${ changedFiles }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user