review changes #2376
Workflow file for this run
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: 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@v2 | |
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/tag-exists-action@v1.0.0 | |
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 "actions@github.com" | |
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 }} |