Merge pull request #37 from srobo/docs/improve-setup-docs #127
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: Validate, Build & maybe Deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: {} | |
jobs: | |
run-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
id: cache-dep | |
with: | |
path: venv | |
key: deps-1-${{ hashfiles('script/requirements.txt') }} | |
- name: Install Dependencies | |
run: | | |
python3 -m venv venv | |
venv/bin/pip install -U pip wheel | |
venv/bin/pip install -r script/requirements.txt | |
venv/bin/pip install . | |
- name: Lint with flake8 | |
run: | | |
source venv/bin/activate | |
./script/linting/lint | |
- name: Typecheck with Mypy | |
if: ${{ always() }} | |
run: | | |
source venv/bin/activate | |
./script/typing/check | |
validate-requirements: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
id: cache-dep | |
with: | |
path: venv | |
key: deps-1-${{ hashfiles('script/requirements.txt') }} | |
- name: Install Dependencies | |
run: | | |
python3 -m venv venv | |
venv/bin/pip install -U pip wheel | |
venv/bin/pip install -r script/requirements.txt | |
- name: Check main dependencies | |
run: | | |
source venv/bin/activate | |
pip-compile && git diff --exit-code | |
- name: Check development dependencies | |
if: ${{ always() }} | |
run: | | |
source venv/bin/activate | |
pip-compile script/requirements.in && git diff --exit-code | |
build-deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
needs: | |
- run-checks | |
- validate-requirements | |
steps: | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build & maybe Push Container | |
uses: docker/build-push-action@v2 | |
id: docker_build | |
with: | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: | | |
ghcr.io/srobo/discord-gated-entry:build-${{ github.run_number }} | |
ghcr.io/srobo/discord-gated-entry:latest | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |