-
Notifications
You must be signed in to change notification settings - Fork 16
90 lines (78 loc) · 3.08 KB
/
workflow.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Models CI/CD
# Trigger every time a push occurs
on:
push:
pull_request:
workflow_dispatch:
paths:
- '!artifacts/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install virtualenv
python -m virtualenv .env
.env/bin/python -m pip install -r requirements.txt
- name: Generate artifacts
# generate all artifacts inside artifacts/ directory
run: |
.env/bin/python build.py
- name: Upload artifacts
# upload all files in the artifacts directory
# the artifact zip is available using the following github API
# curl https://api.github.com/repos/open-traffic-generator/models/actions/artifacts
# the artifact is only available for the amount of time dictated by the
# repo settings which is defaulted to 90 days
uses: actions/upload-artifact@v4
with:
path: artifacts
- name: Generate Doc from openapi.yaml
uses: seeebiii/redoc-cli-github-action@v10
with:
args: 'bundle artifacts/openapi.yaml -o artifacts/openapi.html'
- name: Get version
id: get_version
run: |
echo "::set-output name=version::v$(grep version api/info.yaml | cut -d: -f2 | sed -e 's/ //g')"
- name: Check tag for current version
uses: mukunku/[email protected]
id: check_tag
with:
tag: ${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit openapi.yaml and otg.proto
if: github.event_name != 'pull_request'
id: commit_generated
run: |
git config user.name "Github Actions Bot"
git config user.email "[email protected]"
git add --force artifacts/openapi.yaml
git add --force artifacts/otg.proto
git add --force artifacts/openapi.html
if git status --porcelain | grep .
then
git commit -m "Update auto generated content"
git push
else
echo "No changed auto generated content"
fi
- name: Create release and publish artifacts
if: github.ref == 'refs/heads/master' && steps.check_tag.outputs.exists == 'false'
uses: ncipollo/release-action@v1
with:
name: "Release ${{ steps.get_version.outputs.version }}"
body: "View openapi.yaml spec at https://redocly.github.io/redoc/?url=https://github.com/open-traffic-generator/models/releases/download/${{ steps.get_version.outputs.version }}/openapi.yaml"
artifacts: artifacts/openapi.yaml,artifacts/openapi.json,artifacts/otg.proto,artifacts/openapi.html
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}