Merge branch 'main' into dev #190
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: Update models | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push events for main and dev branches | |
push: | |
branches: [ "main", "dev" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/[email protected] | |
with: | |
python-version: 3.11.3 | |
- name: Get changed threat models | |
id: changed-files-specific | |
uses: tj-actions/changed-files@v36 | |
with: | |
files: ./*.json | |
- name: Validate models | |
id: validate | |
run: | | |
pip install -r requirements.txt | |
python3 src/publish/validate-models.py ${{ steps.changed-files-specific.outputs.all_changed_files }} | |
continue-on-error: true | |
- name: Revert last commit if validation fails | |
if: steps.validate.outcome == 'failure' | |
run: | | |
git revert -m 1 HEAD --no-edit --no-commit | |
- name: slack-send | |
if: steps.validate.outcome == 'failure' | |
uses: slackapi/[email protected] | |
with: | |
# Slack channel ID where message will be posted. Needed if using bot token | |
channel-id: 'C05BY6YNDFF' | |
# Message to post into Slack. Needed if using bot token | |
slack-message: "GitHub threat models validation on branch ${{ github.ref }} failed, commit has been reverted" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
- name: Update models hash and date | |
if: steps.validate.outcome == 'success' | |
run: python3 src/publish/update-models.py ${{ steps.changed-files-specific.outputs.all_changed_files }} | |
- name: Commit & Push changes | |
uses: actions-js/push@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref_name }} |