build: added more detail on cdk deploy #39
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: New Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
# Support running these jobs manually | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install -r src/requirements.txt | |
pip install -r src/app/yolov5/requirements.txt | |
pip install awscli | |
- name: Download data | |
run: | | |
aws s3 cp --no-sign-request s3://902005-public/models/Megadetector/best.pt src/app/model/ | |
aws s3 cp --no-sign-request s3://902005-public/models/Megadetector/labels.txt src/app/model/ | |
- name: Set PYTHONPATH and Run Tests | |
env: | |
PYTHONPATH: src | |
run: pytest | |
semantic_release: | |
runs-on: ubuntu-latest | |
name: Runs semantic release | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: npm install commitizen @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/exec @semantic-release/changelog @semantic-release/npm @semantic-release/git | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: 000000000000000 | |
GIT_AUTHOR_NAME: danellecline | |
GIT_COMMITTER_NAME: danellecline | |
run: npx semantic-release | |
build: | |
name: docker build | |
needs: [ semantic_release ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code and all tags and branches | |
uses: actions/checkout@v2 | |
id: version | |
with: | |
fetch-depth: 0 | |
- name: Get docker tag | |
run: | | |
tag_v=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
tag=$(echo $tag_v | sed 's/v//') | |
if [[ $tag =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
tag="latest" | |
fi | |
echo "Setting TAG=${tag}" | |
echo "TAG=${tag}" >> $GITHUB_ENV | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push to Docker Hub | |
uses: docker/build-push-action@v3 | |
with: | |
context: src | |
push: true | |
tags: | | |
mbari/fastapi-yolov5:${{ env.TAG }} | |
mbari/fastapi-yolov5:latest | |
labels: | | |
IMAGE_URI=mbari/fastapi-yolov5 |