Skip to content

Prophecies - CI

Prophecies - CI #76

Workflow file for this run

name: Prophecies - CI
on:
push:
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
lint-backend:
uses: ./.github/workflows/python_task.yml
with:
python-version: '["3.9"]'
command: poetry run pylint prophecies
test-backend:
uses: ./.github/workflows/python_task.yml
with:
python-version: '["3.9", "3.10"]'
command: make test-back
test-frontend:
uses: ./.github/workflows/node_task.yml
with:
node-version: '["16.x", "18.x"]'
command: make test-front
build:
runs-on: ubuntu-latest
needs: [lint-backend, test-backend, test-frontend]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-3.9-${{ hashFiles('**/poetry.lock') }}
- name: Install Python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Create a docs directory
run: mkdir ./docs
- name: Save OpenAPI schema
run: poetry run python manage.py spectacular --file ./openapi-${GITHUB_SHA}.yml
- name: Upload OpenAPI schema to repository's artifacts
uses: actions/upload-artifact@v4
with:
name: openapi-schemas
path: |
openapi-*.yml
- name: Move and rename OpenAPI schema file to omit the SHA
run: mv openapi-${GITHUB_SHA}.yml prophecies/static/docs/openapi.yml
- name: Fix permissions for Github Pages
run: |
chmod -c -R +rX "prophecies/static/docs/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload docs directory to github-pages artifacts
uses: actions/upload-pages-artifact@v3
with:
path: prophecies/static/docs/
docs-publish:
runs-on: ubuntu-latest
needs: [build]
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy artifact from "github-pages" to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
package-publish:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download all OpenAPI schema artifacts
uses: actions/download-artifact@v4
with:
name: openapi-schemas
- name: Prepare tag name
id: prep
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV
- name: Rename OpenAPI schema file to something human readable
run: mv openapi-${GITHUB_SHA}.yml openapi.yml
- name: Create the release package
uses: softprops/action-gh-release@v1
with:
prerelease: false
generate_release_notes: true
files: openapi.yml
docker-publish:
needs: [build]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Prepare tag name
id: prep
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: icij/prophecies:${{ env.TAG_NAME }},icij/prophecies:latest
platforms: linux/amd64,linux/arm64