From 194c89585488c0ef3998b14b01c1b48cf68b8363 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Apr 2022 15:04:50 +0200 Subject: [PATCH 1/4] ci: Also run tests on pr's to release branches --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eddf199..907362a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ on: pull_request: branches: - master + - releases/* jobs: test-json: From 93ff404f75d22201c13923a601b68a807616cbbc Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Apr 2022 15:13:44 +0200 Subject: [PATCH 2/4] ci: Updated test workflow --- .github/workflows/test.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 907362a..45c65ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -51,7 +51,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -86,7 +86,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -181,7 +181,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -240,7 +240,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -311,7 +311,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -350,7 +350,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -387,7 +387,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -424,7 +424,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -461,7 +461,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -501,7 +501,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -534,7 +534,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -569,7 +569,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" @@ -611,7 +611,7 @@ jobs: - run: npm ci --prod - - run: touch ./fake-file.log + - run: echo "test" > ./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'" From b74fc264fafc009b3d5d78591b886e1ee5bf593b Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Apr 2022 15:16:58 +0200 Subject: [PATCH 3/4] ci: Updated test workflow --- .github/workflows/test.yml | 48 ++++++++++++++------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45c65ad..2d3d746 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -51,10 +50,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -86,10 +84,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - run: touch ./test-file-empty.json @@ -127,7 +124,7 @@ jobs: - run: git tag | xargs git tag -d - name: Create fake tag run: "git tag -a 'v0.55.8' -m 'v0.55.8'" - - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" + - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -156,7 +153,7 @@ jobs: - run: git tag | xargs git tag -d - name: Create fake tag run: "git tag -a 'v0.55.8' -m 'v0.55.8'" - - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" + - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -181,10 +178,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - run: git tag | xargs git tag -d @@ -215,7 +211,7 @@ jobs: - run: git tag | xargs git tag -d - name: Create fake tag run: "git tag -a 'v0.55.8' -m 'v0.55.8'" - - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" + - run: "git add . && git commit --allow-empty -m 'fix: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -240,10 +236,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -311,10 +306,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - run: touch ./test-file-empty.yaml @@ -350,10 +344,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -387,10 +380,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -424,10 +416,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -461,10 +452,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - run: touch ./test-file-empty.toml @@ -501,10 +491,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -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 @@ -534,10 +523,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -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 @@ -569,10 +557,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate changelog id: changelog @@ -611,10 +598,9 @@ jobs: - run: npm ci --prod - - run: echo "test" > ./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 add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" - name: Generate Changelog id: changelog From a0bcde8dcf6c731817d1142609d778fd4367ae05 Mon Sep 17 00:00:00 2001 From: Asger Jensen Date: Tue, 24 May 2022 17:03:45 +0200 Subject: [PATCH 4/4] feat: add [skip ci] by default to commit message This is useful when you are working on an organizational repository where you are passing in a custom admin token as any pushes with this token, will cause a new build to be scheduled. This adds the [skip ci] instruction by default. With an option to supress it --- .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++++++ README.md | 1 + action.yml | 4 ++++ src/helpers/git.js | 8 ++++++-- src/index.js | 7 ++++++- 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d3d746..5aaef6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -620,3 +620,42 @@ jobs: else echo "Changelog config not applied" && exit 1 fi + + + test-skip-ci: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + path: "./" + + - run: npm ci --prod + + - run: "git config --global user.email 'changelog@github.com'" + - run: "git config --global user.name 'Awesome Github action'" + - run: "git add . && git commit --allow-empty -m 'feat: Added fake file so version will be bumped'" + + - name: Generate changelog + id: changelog + uses: ./ + env: + ENV: 'dont-use-git' + EXPECTED_TAG: 'v1.5.0' + SKIP_CI: 'false' + with: + github-token: ${{ secrets.github_token }} + version-file: 'test-file.json' + skip-ci: 'false' + + - name: Show file + run: | + echo "$( { if (ENV === 'dont-use-git') { - const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL } = process.env + const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH, SKIPPED_PULL, SKIP_CI } = process.env const expectedCommands = [ 'git config user.name "Conventional Changelog Action"', @@ -174,7 +174,11 @@ module.exports = new (class Git { if (!SKIPPED_COMMIT) { expectedCommands.push('git add .') - expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG}"`) + if (SKIP_CI === false) { + expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG}"`) + } else { + expectedCommands.push(`git commit -m "chore(release): ${EXPECTED_TAG} [skip ci]"`) + } } expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`) diff --git a/src/index.js b/src/index.js index 2220c0f..157e9e7 100644 --- a/src/index.js +++ b/src/index.js @@ -25,7 +25,7 @@ async function handleVersioningByExtension(ext, file, versionPath, releaseType) async function run() { try { - const gitCommitMessage = core.getInput('git-message') + let gitCommitMessage = core.getInput('git-message') const gitUserName = core.getInput('git-user-name') const gitUserEmail = core.getInput('git-user-email') const gitPush = core.getInput('git-push').toLowerCase() === 'true' @@ -42,6 +42,11 @@ async function run() { const skipEmptyRelease = core.getInput('skip-on-empty').toLowerCase() === 'true' const conventionalConfigFile = core.getInput('config-file-path') const preChangelogGenerationFile = core.getInput('pre-changelog-generation') + const skipCi = core.getInput('skip-ci') + + if (skipCi) { + gitCommitMessage += " [skip ci]" + } core.info(`Using "${preset}" preset`) core.info(`Using "${gitCommitMessage}" as commit message`)