From 34b6a1f85a48c42fcadf44b511d2991b5424c718 Mon Sep 17 00:00:00 2001 From: Subeom Choi Date: Thu, 27 Jun 2024 13:12:25 +0900 Subject: [PATCH 1/4] feature: add Unreleased to changelog if necessary --- .github/workflows/gitflow.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gitflow.yml b/.github/workflows/gitflow.yml index 2d8de92..6ebaf7b 100644 --- a/.github/workflows/gitflow.yml +++ b/.github/workflows/gitflow.yml @@ -187,6 +187,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: + ref: ${{ env.SOURCE_BRANCH }} token: ${{ env.TOKEN }} - name: Checkout commit @@ -203,6 +204,15 @@ jobs: run: | cat ${{ env.CHANGELOG }} \ | grep '^${{ env.VERSION_HEADER }}Unreleased$' \ + || ( \ + echo "$(printf '${{ env.VERSION_HEADER }}Unreleased\n\n' | cat - ${{ env.CHANGELOG }})" > ${{ env.CHANGELOG }}; \ + git config user.name github-actions; \ + git config user.email github-actions@github.com; \ + git add ${{ env.CHANGELOG }}; \ + git commit -m "document: add Unreleased to ${{ env.CHANGELOG }}"; \ + git push; \ + ) \ + && (echo 'warning=changelog-not-modified' >> $GITHUB_OUTPUT; exit 0) \ || (echo 'failure=changelog-not-contains-unreleased' >> $GITHUB_OUTPUT; exit 1) git diff --name-only ${{ env.DESTINATION_COMMIT }} \ | grep --perl-regexp 'changelog\.md' \ @@ -246,13 +256,12 @@ jobs: return `I recommend that you should modify ${{ env.CHANGELOG }}.` } })() - const response = await github.rest.issues.listComments({ + const { data: comments } = await github.rest.issues.listComments({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - }); - const comments = response.map(json => json.body) - if (comments.some(comment => comment === message)) { + }) + if (comments.some(comment => comment.body === message)) { return } github.rest.issues.createComment({ From 1ac52ad80d629f831d7c45a729c517abb73cfec7 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 27 Jun 2024 04:17:50 +0000 Subject: [PATCH 2/4] document: add Unreleased to changelog.md --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 9c62a1e..70200df 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +## Unreleased + ## 2.2.1 - fix: use TOKEN instead of GITHUB_TOKEN From 31def7bfcaaa951a38abf605198645fd8a621fc7 Mon Sep 17 00:00:00 2001 From: Subeom Choi Date: Thu, 27 Jun 2024 13:18:55 +0900 Subject: [PATCH 3/4] document: update changelog --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 70200df..a53dbd3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ ## Unreleased +- document: add Unreleased to changelog.md + ## 2.2.1 - fix: use TOKEN instead of GITHUB_TOKEN From 36b267101fee4923cd7276d133b2bafb18b9b286 Mon Sep 17 00:00:00 2001 From: Subeom Choi Date: Thu, 27 Jun 2024 13:22:09 +0900 Subject: [PATCH 4/4] update: use version 2.2.2 --- changelog.md | 2 +- readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index a53dbd3..4da271e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,4 @@ -## Unreleased +## 2.2.2 - document: add Unreleased to changelog.md diff --git a/readme.md b/readme.md index f4749e5..0632747 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,7 @@ changelog.md ``` 1. Create (`${FEATURE_TYPE}/name` to `develop`) pull request. -2. GitHub Actions automatically check changelog.md has `## Unreleased`, if not close pull request. +2. GitHub Actions automatically check changelog.md has `## Unreleased`, if possible add `## Unreleased` to changelog.md and commit and push, if not close pull request. 3. GitHub Actions automatically check changelog.md has modification, if not add recommend comment to pull request. 4. Merge. 5. GitHub Actions automatically delete `${FEATURE_TYPE}/name` branch.