Skip to content

fix: add make to ci #33

fix: add make to ci

fix: add make to ci #33

Workflow file for this run

name: ELK-FastAPI
on:
pull_request:
push:
branches:
- main
permissions:
contents: write
id-token: write
pull-requests: write
repository-projects: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Install Poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Cache dependencies
uses: actions/cache@v3
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Set poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install dependencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
- name: Lint with task
run: make format
- name: Test with Pytest
run: make test
- name: Build Dist
run: make build
release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions: write-all
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install dependencies
run: poetry install
- name: Prepare package for release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
VERSION=$(poetry run semantic-release version | awk '{print $NF}')
TAG_NAME=${VERSION#v}
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
poetry run semantic-release publish --tag $TAG_NAME
- name: Set up Git for release
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: Release ${{ env.TAG_NAME }}
draft: false
prerelease: false
- name: Upload package to GitHub Packages
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.TAG_NAME }} .
docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.TAG_NAME }}