build #98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- develop | |
tags: | |
- "*" | |
workflow_dispatch: | |
schedule: | |
# Every Month, the first day at 8:42 | |
- cron: "42 8 1 * *" | |
jobs: | |
build_analyzers: | |
name: Build Analyzers | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Checkout neurons builder | |
uses: actions/checkout@v4 | |
with: | |
repository: TheHive-Project/cortex-neurons-builder | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Build analyzers | |
run: | | |
python build.py --namespace cortexneurons --path analyzers --registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} --registry_harbor ${{ secrets.REGISTRY_HARBOR }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }} | |
build_responders: | |
name: Build Responders | |
runs-on: [ ubuntu-latest ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Checkout neurons builder | |
uses: actions/checkout@v4 | |
with: | |
repository: TheHive-Project/cortex-neurons-builder | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Build responders | |
run: | | |
python build.py --namespace cortexneurons --path responders --registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} --registry_harbor ${{ secrets.REGISTRY_HARBOR }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }} | |
build_catalog: | |
name: Build Catalog | |
runs-on: [ ubuntu-latest ] | |
needs: [ build_analyzers, build_responders ] | |
if: always() | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Build catalog | |
run: | | |
build_catalog() { | |
DIR=$1 | |
echo '[' > ${DIR}/${DIR}.json | |
echo '[' > ${DIR}/${DIR}-devel.json | |
echo '[' > ${DIR}/${DIR}-stable.json | |
first=1 | |
for JSON in ${DIR}/*/*.json | |
do | |
if test -z "${first}" | |
then | |
echo ',' >> ${DIR}/${DIR}.json | |
echo ',' >> ${DIR}/${DIR}-devel.json | |
echo ',' >> ${DIR}/${DIR}-stable.json | |
else | |
first= | |
fi | |
jq 'del(.command) + { dockerImage: ("docker.io/cortexneurons/" + (.name | ascii_downcase) + ":devel") }' ${JSON} >> ${DIR}/${DIR}-devel.json | |
jq 'del(.command) + { dockerImage: ("docker.io/cortexneurons/" + (.name | ascii_downcase) + ":" + .version) }' ${JSON} >> ${DIR}/${DIR}-stable.json | |
jq 'del(.command) + { dockerImage: ("docker.io/cortexneurons/" + (.name | ascii_downcase) + ":" + (.version | split("."))[0]) }' ${JSON} >> ${DIR}/${DIR}.json | |
done | |
echo ']' >> ${DIR}/${DIR}.json | |
echo ']' >> ${DIR}/${DIR}-devel.json | |
echo ']' >> ${DIR}/${DIR}-stable.json | |
} | |
build_catalog analyzers | |
build_catalog responders | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: Build report-templates zip package | |
run: zip -r ../analyzers/report-templates.zip * | |
working-directory: thehive-templates | |
- name: Save Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: catalog | |
path: | | |
analyzers/analyzers.json | |
analyzers/report-templates.zip | |
responders/responders.json | |
- name: Make Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
generate_release_notes: true | |
files: | | |
analyzers/analyzers-stable.json | |
analyzers/analyzers.json | |
analyzers/report-templates.zip | |
responders/responders-stable.json | |
responders/responders.json | |
build_docs: | |
name: Build documentation | |
runs-on: [ ubuntu-latest ] | |
needs: [build_analyzers, build_responders ] | |
if: startsWith(github.ref, 'refs/tags/') && always() | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Prepare documentation files | |
uses: docker://thehiveproject/doc-builder | |
with: | |
args: --type Cortex-Neurons | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.x" | |
architecture: x64 | |
- name: Install requirements | |
run: python3 -m pip install -r utils/test_doc/requirements.txt | |
- name: setup git user | |
run: git config user.name 'github-actions[bot]' && git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Deploy | |
run: python3 -m mkdocs gh-deploy --remote-branch gh-pages --force | |
notify: | |
needs: [build_analyzers, build_responders, build_catalog, build_docs ] | |
runs-on: [ ubuntu-latest ] | |
if: always() | |
steps: | |
- name: Slack notification | |
uses: Gamesight/slack-workflow-status@master | |
with: | |
repo_token: ${{secrets.GITHUB_TOKEN}} | |
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} | |
channel: "#ci-cortex" | |
name: Cortex Analyzers build | |
include_commit_message: true | |
include_jobs: true |