fix: Fixed silent git errors #74
parent
d55112e04c
commit
7c35f3c286
|
@ -11,7 +11,6 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
|
@ -34,6 +33,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -58,6 +61,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: touch ./test-file-empty.json
|
||||
|
||||
|
@ -81,6 +88,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: test -f pre-commit.test.json && (echo should not be here yet && exit 1) || exit 0
|
||||
|
||||
|
@ -107,6 +118,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: test -f pre-changelog-generation.test.json && (echo should not be here yet && exit 1) || exit 0
|
||||
|
||||
|
@ -136,6 +151,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -155,6 +174,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: git tag | xargs git tag -d
|
||||
|
||||
|
@ -176,6 +199,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -196,6 +223,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: touch ./test-file-empty.yaml
|
||||
|
||||
|
@ -220,6 +251,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -242,6 +277,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -262,6 +301,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -284,6 +327,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- run: touch ./test-file-empty.toml
|
||||
|
||||
|
@ -308,6 +355,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
|
@ -327,6 +378,10 @@ jobs:
|
|||
path: "./"
|
||||
|
||||
- run: npm ci --prod
|
||||
- run: touch ./fake-file.log
|
||||
- run: "git config --global user.email 'changelog@github.com'"
|
||||
- run: "git config --global user.name 'Awesome Github action'"
|
||||
- run: "git add . && git commit -m 'feat: Added fake file so version will be bumped'"
|
||||
|
||||
- name: Generate Changelog
|
||||
id: changelog
|
||||
|
|
|
@ -86,7 +86,8 @@ inputs:
|
|||
fallback-version:
|
||||
description: 'The fallback version, if no older one can be detected, or if it is the first one'
|
||||
default: '0.1.0'
|
||||
|
||||
required: false
|
||||
|
||||
config-file-path:
|
||||
description: 'Path to the conventional changelog config file. If set, the preset setting will be ignored'
|
||||
required: false
|
||||
|
|
|
@ -37,28 +37,14 @@ module.exports = new (class Git {
|
|||
* @param command
|
||||
* @return {Promise<>}
|
||||
*/
|
||||
exec = command => new Promise(async(resolve, reject) => {
|
||||
let myOutput = ''
|
||||
let myError = ''
|
||||
exec = (command) => new Promise(async(resolve, reject) => {
|
||||
const exitCode = await exec.exec(`git ${command}`)
|
||||
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
myOutput += data.toString()
|
||||
},
|
||||
stderr: (data) => {
|
||||
myError += data.toString()
|
||||
},
|
||||
},
|
||||
}
|
||||
if (exitCode === 0) {
|
||||
resolve()
|
||||
|
||||
try {
|
||||
await exec.exec(`git ${command}`, null, options)
|
||||
|
||||
resolve(myOutput)
|
||||
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
} else {
|
||||
reject(`Command "git ${command}" exited with code ${exitCode}.`)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -77,7 +63,7 @@ module.exports = new (class Git {
|
|||
* @param file
|
||||
* @returns {*}
|
||||
*/
|
||||
add = file => this.exec(`add ${file}`)
|
||||
add = (file) => this.exec(`add ${file}`)
|
||||
|
||||
/**
|
||||
* Commit all changes
|
||||
|
@ -124,7 +110,7 @@ module.exports = new (class Git {
|
|||
*
|
||||
* @return {Promise<>}
|
||||
*/
|
||||
isShallow = async () => {
|
||||
isShallow = async() => {
|
||||
const isShallow = await this.exec('rev-parse --is-shallow-repository')
|
||||
|
||||
// isShallow does not return anything on local machine
|
||||
|
@ -141,7 +127,7 @@ module.exports = new (class Git {
|
|||
* @param repo
|
||||
* @return {Promise<>}
|
||||
*/
|
||||
updateOrigin = repo => this.exec(`remote set-url origin ${repo}`)
|
||||
updateOrigin = (repo) => this.exec(`remote set-url origin ${repo}`)
|
||||
|
||||
/**
|
||||
* Creates git tag
|
||||
|
@ -149,6 +135,6 @@ module.exports = new (class Git {
|
|||
* @param tag
|
||||
* @return {Promise<>}
|
||||
*/
|
||||
createTag = tag => this.exec(`tag -a ${tag} -m "${tag}"`)
|
||||
createTag = (tag) => this.exec(`tag -a ${tag} -m "${tag}"`)
|
||||
|
||||
})()
|
||||
|
|
|
@ -172,12 +172,7 @@ async function run() {
|
|||
await git.createTag(gitTag)
|
||||
|
||||
core.info('Push all changes')
|
||||
try {
|
||||
await git.push()
|
||||
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
await git.push()
|
||||
|
||||
// Set outputs so other actions (for example actions/create-release) can use it
|
||||
core.setOutput('changelog', stringChangelog)
|
||||
|
@ -187,7 +182,7 @@ async function run() {
|
|||
core.setOutput('skipped', 'false')
|
||||
})
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
core.setFailed(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue