mirror of
https://github.com/mandiant/capa-rules
synced 2026-06-08 15:41:20 +00:00
341a2fca5c
The default `ref` is the one which triggers the action. Consequently the ` Update rules number badge` commit from the `update_num_rules` job is not synchronized.
60 lines
2.0 KiB
YAML
60 lines
2.0 KiB
YAML
name: Update rules number badge and sync rules submodule in capa
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
jobs:
|
|
update_num_rules:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout capa-rules
|
|
uses: actions/checkout@v2
|
|
- name: Update rules number badge in README
|
|
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@fireeye.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
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
sync_submodule_capa:
|
|
runs-on: ubuntu-latest
|
|
needs: update_num_rules
|
|
steps:
|
|
# Do not checkout submodules as we don't need capa-testfiles and we need to
|
|
# update the rules submodule reference
|
|
- name: Checkout capa
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: fireeye/capa
|
|
token: ${{ secrets.CAPA_TOKEN }}
|
|
- name: Checkout capa-rules
|
|
uses: actions/checkout@v2
|
|
with:
|
|
# To include the commit from update_num_rules (the default `ref` is the
|
|
# one which triggered the action)
|
|
ref: master
|
|
path: rules
|
|
- 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: Commit changes
|
|
run: |
|
|
git config user.email 'capa-dev@fireeye.com'
|
|
git config user.name 'Capa Bot'
|
|
git commit -am 'Sync capa rules submodule'
|
|
- name: Push changes to capa
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
repository: fireeye/capa
|
|
github_token: ${{ secrets.CAPA_TOKEN }}
|
|
|