chore: tweak workflows for staging and production environments #254
Workflow file for this run
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 | |
on: | |
pull_request: | |
branches: | |
- "*" | |
push: | |
branches: | |
- develop | |
env: | |
IMAGE_NAME: unitystation/central-command | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
# because pre-commit uses external mypy | |
- name: install mypy | |
run: | | |
pip install poetry | |
poetry config virtualenvs.create false | |
poetry install --only main,typecheck | |
# https://github.com/typeddjango/django-stubs/issues/458 | |
- name: create .env file | |
run: cp example.env .env | |
- uses: pre-commit/[email protected] | |
unit_test: | |
needs: [ lint ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
poetry config virtualenvs.create false | |
poetry install --only main | |
- name: create .env file | |
run: cp example.env .env | |
- name: Run tests | |
env: | |
SECRET_KEY: secret | |
DB_ENGINE: django.db.backends.sqlite3 | |
run: | | |
cd src | |
python manage.py makemigrations --check | |
python manage.py migrate | |
python manage.py test tests/ | |
docker: | |
needs: [ lint, unit_test ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build docker image | |
run: | | |
docker pull $IMAGE_NAME | |
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME:latest . | |
- name: Log in into Docker Hub | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- name: Push image to registry | |
if: ${{ github.event_name == 'push' }} | |
run: | | |
docker push $IMAGE_NAME |