Skip to content

version readme (#22) #157

version readme (#22)

version readme (#22) #157

Workflow file for this run

name: CI/CD
# Trigger every time a push occurs
on:
push:
pull_request:
paths:
- '!artifacts/**'
workflow_dispatch:
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: |-
Creates a clean environment
Generates openapiart artifacts
Builds the package
Installs the package
Runs pytest tests
Builds yaml from src devices and infrastructures
Builds docs site using src and generated yaml
run: |
make clean
make install
make test
make docs
- name: Generate Doc from openapi.yaml
uses: seeebiii/redoc-cli-github-action@v10
with:
args: 'bundle artifacts/openapi.yaml -o docs/src/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: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: artifacts
- name: Commit generated artifacts
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/infragraph.proto
git add --force docs/src/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/main' && steps.check_tag.outputs.exists == 'false'
uses: ncipollo/release-action@v1
with:
name: "Release ${{ steps.get_version.outputs.version }}"
body: |-
The OpenAPI schema for this release (openapi.yaml) is included as part of the assets and can be viewed by loading the included openapi.html document in a browser.
artifacts: artifacts/openapi.yaml,artifacts/openapi.json,artifacts/infragraph.proto,docs/src/openapi.html,dist/*.*
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy artifacts
if: github.ref == 'refs/heads/main' && steps.check_tag.outputs.exists == 'false'
run: |
make deploy PYPI_TOKEN=${{ secrets.PYPI_TOKEN }}
- name: Github Pages deploy
if: github.ref == 'refs/heads/main'
run: |
source .venv/bin/activate && python3 -m mkdocs gh-deploy --force --config-file docs/mkdocs.yml --site-dir docs/site --remote-branch gh-pages