Feature/download endpoint #21
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: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10.6 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
pytest -v app/tests | |
build: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Read the VERSION file | |
id: get_version | |
run: | | |
echo "VERSION=$(cat VERSION)" >> "$GITHUB_OUTPUT" | |
- name: Build and tag Docker image | |
uses: docker/build-push-action@v5 | |
env: | |
VERSION: ${{ steps.get_version.outputs.version }} | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/inab/observatory-api:$VERSION | |
ghcr.io/inab/observatory-api:latest | |
tag: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Git user for tagging | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create Git tag with version | |
env: | |
VERSION: ${{ steps.get_version.outputs.version }} | |
run: | | |
git tag -a v$VERSION -m "Version $VERSION" | |
git push origin v$env.VERSION | |