-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: models validation w/ auto revert of commit
- Loading branch information
1 parent
8761fcf
commit a041ee2
Showing
3 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,43 +2,58 @@ name: Update models | |
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push events but only for the "dev" branch | ||
# Triggers the workflow on push events for main and dev branches | ||
push: | ||
branches: [ "dev", "workflow-tests" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
branches: [ "main", "dev" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
# Fetch all last commits | ||
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: Update models hash and date | ||
run: | | ||
python3 src/publish/update-models.py ${{ steps.changed-files-specific.outputs.all_changed_files }} | ||
- name: Validate models | ||
run: | | ||
python3 src/publish/validate-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: dev | ||
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: Update models hash and date | ||
run: python3 src/publish/update-models.py ${{ steps.changed-files-specific.outputs.all_changed_files }} | ||
|
||
- name: Validate models | ||
id: validate | ||
run: 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 HEAD --no-edit | ||
git push origin ${{ github.ref_name }} | ||
- 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: Commit & Push changes | ||
if: steps.validate.outcome == 'success' | ||
uses: actions-js/push@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref_name }} |
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