Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Use badge in gist for rules number in README #882

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
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.