forked from microsoft/olive-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.63 KB
/
scanner.yml
File metadata and controls
59 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: scanner
description: "CI workflow to scan and populate model directory tables in README.md"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- main
env:
PYTHON_VERSION: "3.10"
GHA_PR_BRANCH: "gha/update-$${{ github.run_id }}"
jobs:
scan:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # ref is required as GitHub Actions checks out in detached HEAD mode
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies and run scanner
run: |
python -m pip install pyyaml
python .github/scripts/scanner.py --dirpath . --verbose
- name: Check for Changes
id: check_changes
run: |
if [[ -n "$(git diff --exit-code)" ]]; then
echo "Changes detected."
echo "::set-output name=has_changes::true"
else
echo "No changes detected."
echo "::set-output name=has_changes::false"
fi
- name: Create a new branch for the PR
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b "${{ env.GHA_PR_BRANCH }}"
git add README.md
git commit -m "[Scanner]: Ran scanner and update README.md"
git push origin "${{ env.GHA_PR_BRANCH }}"