Add YOLOv5 Python Postprocesses #174
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: Build documentations on comment | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
test-doc-generator-by-pr-number: | |
if: (contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/gen-doc')) | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
path: furiosa-models | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: make docs | |
env: | |
BODY: ${{ github.event.comment.body }} | |
GH_TOKEN: ${{ github.token }} | |
ISSUE: ${{ github.event.issue.html_url }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
run: | | |
cd ./furiosa-models | |
export GIT_HASH=$(git rev-parse --short HEAD) | |
export ISSUE_URL=$(echo $ISSUE | cut -d'/' -f-5) | |
export DOCS_PATH="PR-$ISSUE_NUMBER" | |
echo "Git short hash: $GIT_HASH" | |
echo "Documentation version: $DOCS_PATH" | |
echo "Issue URL base: $ISSUE_URL" | |
# install documentation requirements | |
pip install -r ./docs/requirements.txt | |
# generate documentation | |
mkdocs build --site-dir ../$DOCS_PATH | |
# checkout to gh-pages | |
git checkout gh-pages | |
cp -r ../$DOCS_PATH . | |
git add . | |
# if no change in docs repo, quit | |
if git diff --cached --exit-code > /dev/null; then echo "no change"; exit 1; fi | |
git config user.email "[email protected]" | |
git config user.name "furiosa-infra" | |
git commit -m "docs: auto generated by furiosa-models#$ISSUE_NUMBER | |
related commit: $ISSUE_URL/commit/$GIT_HASH" | |
export DOCS_COMMIT=$(git rev-parse --short HEAD) | |
git push | |
# if we run `gh run list` right after push, we'll miss the latest commit | |
sleep 5 | |
export RUN_ID=$(gh run list | head -n 1 | grep -Po "[\d]{10}") | |
echo "RUN_ID: $RUN_ID" | |
gh run watch $RUN_ID | |
# github comment | |
gh issue comment -R $ISSUE_URL $ISSUE_NUMBER --body "Documentation generated by $DOCS_PATH successfully! | |
Documentation commit: https://github.com/furiosa-ai/furiosa-models/commit/$DOCS_COMMIT | |
Documentation URL: https://furiosa-ai.github.io/furiosa-models/$DOCS_PATH/" | |
release-doc-generator-by-given-version: | |
if: (contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/release-doc')) | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
path: furiosa-models | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: make docs | |
env: | |
BODY: ${{ github.event.comment.body }} | |
GH_TOKEN: ${{ github.token }} | |
ISSUE: ${{ github.event.issue.html_url }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
run: | | |
cd ./furiosa-models | |
export GIT_HASH=$(git rev-parse --short HEAD) | |
export ISSUE_URL=$(echo $ISSUE | cut -d'/' -f-5) | |
export DOCS_PATH=$(echo $BODY | head -n 1 | cut -d'/' -f3 | xargs) # use xargs to trim ws/newline chars | |
echo "Git short hash: $GIT_HASH" | |
echo "Issue URL base: $ISSUE_URL" | |
if [ ! $(echo "$DOCS_PATH" | grep -P "v([0-9]+\.){2}[0-9]+") ]; then | |
gh issue comment -R $ISSUE_URL $ISSUE_NUMBER --body "Docs version is malformed, it should be v\d+\.\d+\.\d+ format"; | |
exit 1; | |
fi | |
# install documentation requirements | |
pip install -r ./docs/requirements.txt | |
# generate documentation | |
mkdocs build --site-dir ../$DOCS_PATH | |
# checkout to gh-pages | |
git checkout gh-pages | |
cp -r ../$DOCS_PATH . | |
# update latest symbolic link | |
rm latest | |
ln -s $DOCS_PATH latest | |
git add . | |
# if no change in docs repo | |
if git diff --cached --exit-code > /dev/null; then echo "no change"; exit 1; fi | |
git config user.email "[email protected]" | |
git config user.name "furiosa-infra" | |
git commit -m "docs: auto generated by furiosa-models#$ISSUE_NUMBER | |
related commit: $ISSUE_URL/commit/$GIT_HASH" | |
export DOCS_COMMIT=$(git rev-parse --short HEAD) | |
git push | |
# if we run `gh run list` right after push, we'll miss the latest commit | |
sleep 5 | |
export RUN_ID=$(gh run list | head -n 1 | grep -Po "[\d]{10}") | |
echo "RUN_ID: $RUN_ID" | |
gh run watch $RUN_ID | |
# github comment | |
gh issue comment -R $ISSUE_URL $ISSUE_NUMBER --body "Documentation generated by $DOCS_PATH successfully! | |
Documentation commit: https://github.com/furiosa-ai/furiosa-models/commit/$DOCS_COMMIT | |
Documentation URL: https://furiosa-ai.github.io/furiosa-models/$DOCS_PATH/" |