Skip to content

Commit

Permalink
Merge remote-tracking branch 'auto-merge/mergeable/auto-changelog'
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwDayDream committed Jun 11, 2024
2 parents aea23b4 + 58288f0 commit fe32670
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/auto-pr-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
name: "Auto Changelog"

on:
issue_comment:
types: [created]
pull_request:
types: [labeled, unlabeled]

jobs:
auto-changelog:
if: ${{ github.event.label.name == 'Changelog' }}
env:
COMMENT_BODY: ${{ github.event.comment.body }}
if: ${{ (contains(github.event.comment.body, '+changelog') || contains(github.event.comment.body, '-changelog')) && github.event.comment.user.login == github.event.issue.user.login }}
LABEL_ADDED: ${{ github.event.action == 'labeled' }}
PR_TITLE: ${{ github.event.pull_request.title }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
clean: false
fetch-depth: 0
filter: tree:0

- run: |
git branch --track ${{ github.base_ref }} origin/${{ github.base_ref }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
Expand All @@ -27,14 +33,15 @@ jobs:
- name: Reset Changelog
continue-on-error: true
run: |
git checkout ${{ github.ref_name }} -- ./README.md
rm CHANGELOG.md
git checkout ${{ github.base_ref }} -- CHANGELOG.md
- name: CHANGELOG Setup
if: ${{ contains(github.event.comment.body, '+changelog') }}
if: ${{ env.LABEL_ADDED == 'true' }}
uses: actions/github-script@v7
env:
HEAD_REF: ${{ github.head_ref }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_TITLE: ${{ env.PR_TITLE }}
with:
script: |
const fs = require('fs');
Expand Down Expand Up @@ -173,6 +180,7 @@ jobs:
console.log(headRef);
var category = headRef.split('/')[0];
var potentialHead = masterHead.changelog.unreleased[category];
console.log(potentialHead);
if (potentialHead != null) {
potentialHead.children.push('- ' + process.env.ISSUE_TITLE);
}
Expand All @@ -182,9 +190,10 @@ jobs:
console.log("-=-=-=-=-\nWhat we have exported...");
console.log(masterHead.toString());
- run: |
- continue-on-error: true
run: |
git add .
git commit -am "Updated README.md"
git commit -am "Updated CHANGELOG.md"
- name: PR Check
id: pr-check
Expand Down

0 comments on commit fe32670

Please sign in to comment.