Skip to content

Commit

Permalink
[CI] Use badge in gist for rules number in README
Browse files Browse the repository at this point in the history
This simplifies the workflow code and remove the need for the noisy
commits in capa-rules. We still need the commits in capa to sync the
submodule.
  • Loading branch information
Ana06 committed Feb 23, 2024
1 parent 34e3755 commit 4c03f00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ jobs:
steps:
- name: Checkout capa-rules
uses: actions/checkout@v3
- name: Update rules number badge in README
- name: Count rules
run: |
num_rules=$(find . -type f -name '*.yml' -not -path './.github/*' | wc -l)
sed -i "s/rules-[0-9]*-blue\.svg/rules-$num_rules-blue.svg/" README.md
- name: Commit changes
run: |
git config user.email 'capa-dev@mandiant.com'
git config user.name 'Capa Bot'
# Do not fail the action if rules number doesn't change
git add -A
git diff-index --quiet HEAD || git commit -am 'Update rules number badge'
- name: Push changes to capa-rules
uses: ad-m/github-push-action@master
echo "num_rules=$num_rules" >> $GITHUB_ENV
- name: Update dynamic badge gist
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auth: ${{ secrets.GITHUB_TOKEN }}
gistID: 6d7960e911f48b3b74916df8988cf0f3
filename: rules_badge.svg
label: rules
message: ${{ env.num_rules }}
color: blue

sync_submodule_capa:
runs-on: ubuntu-20.04
Expand All @@ -43,10 +41,6 @@ jobs:
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 | grep .yml | wc -l)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# capa rules

[![Rule linter status](https://github.com/mandiant/capa-rules/workflows/CI/badge.svg)](https://github.com/mandiant/capa-rules/actions?query=workflow%3A%22CI%22)
[![Number of rules](https://img.shields.io/badge/rules-871-blue.svg)](rules)
[![Number of rules](https://gist.githubusercontent.com/capa-bot/6d7960e911f48b3b74916df8988cf0f3/raw/rules_badge.svg)](rules)
[![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE.txt)

This is the standard collection of rules for [capa](https://github.com/mandiant/capa) - the tool to automatically identify capabilities of programs.
Expand Down

0 comments on commit 4c03f00

Please sign in to comment.