Skip to content

Commit

Permalink
ci: Update CHANGELOG automatically
Browse files Browse the repository at this point in the history
Update new rules in capa repository's CHANGELOG with a GitHub Action
automatically with every push (for example merge of PR).
  • Loading branch information
Ana06 committed May 7, 2021
1 parent a1a9213 commit 9ceef75
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,27 @@ jobs:
# one which triggered the action)
ref: master
path: rules
fetch-depth: 100 # needed so that `git diff` finds `github.event.before`
- name: Update rules number badge in README
run: |
num_rules=$(find rules -type f -name '*.yml' -not -path 'rules/.github/*' | wc -l)
sed -i "s/rules-[0-9]*-blue\.svg/rules-$num_rules-blue.svg/" README.md
- name: Update number of new rules in CHANGELOG
run: |
new_rules=$(git -C rules diff -M --summary ${{ github.event.before }} | grep create | wc -l)
old_rules=$(grep -m 1 "### New Rules.*" CHANGELOG.md | sed -r 's/.*\((.*)\)/\1/')
rules=$(($old_rules + $new_rules))
sed -ir "0,/New Rules.*/s//New Rules \($rules\)/" CHANGELOG.md
- name: Get modified files
id: files
uses: jitterbit/get-changed-files@v1
- name: Add new rules to CHANGELOG
run: |
for added_file in ${{ steps.files.outputs.added }}; do
author=$(grep 'author:' rules/$added_file | sed 's/^.*: //' | sed 's/"//g' )
rule=$(echo $added_file | sed 's/\//\\\//g' | sed 's/\.yml//')
sed -i "0,/- *$/s//- $rule $author\n-/" CHANGELOG.md
done
- name: Commit changes
run: |
git config user.email '[email protected]'
Expand Down

0 comments on commit 9ceef75

Please sign in to comment.