From da8d8eedee93b2558b41c7c3dba189596a58c245 Mon Sep 17 00:00:00 2001 From: Graham Hoyes Date: Mon, 2 Aug 2021 15:25:42 -0400 Subject: [PATCH] Split workflows into checks and deploy, add prod environment --- .github/workflows/checks.yml | 30 +++++++++++++++++ .github/workflows/{main.yml => deploy.yml} | 38 +++++----------------- 2 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/checks.yml rename .github/workflows/{main.yml => deploy.yml} (83%) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..72a526a --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,30 @@ +name: Checks + +on: + push: + branches: + - '**' + +jobs: + checks: + runs-on: ubuntu-latest + defaults: + run: + working-directory: app + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Lint + run: black --check . + - name: Tests + env: + SECRET_KEY: ${{ secrets.CI_SECRET_KEY }} + run: python manage.py test --settings=app.settings.ci diff --git a/.github/workflows/main.yml b/.github/workflows/deploy.yml similarity index 83% rename from .github/workflows/main.yml rename to .github/workflows/deploy.yml index 3c357c2..ed8340f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ -name: CI/CD +name: Deploy on: - push: - branches: - - '**' + release: + types: + - 'released' env: REGISTRY: ghcr.io @@ -11,33 +11,9 @@ env: STACK_NAME: django-swarm-example jobs: - checks: - runs-on: ubuntu-latest - defaults: - run: - working-directory: app - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Lint - run: black --check . - - name: Tests - env: - SECRET_KEY: ${{ secrets.CI_SECRET_KEY }} - run: python manage.py test --settings=app.settings.ci build: runs-on: ubuntu-latest - needs: [checks] - if: github.ref == 'refs/heads/master' outputs: GITHUB_SHA_SHORT: ${{ steps.sha7.outputs.GITHUB_SHA_SHORT }} @@ -62,8 +38,10 @@ jobs: deploy: runs-on: ubuntu-latest - needs: [checks, build] - if: github.ref == 'refs/heads/master' + needs: [build] + environment: + name: production + url: https://django-swarm-example.grahamhoyes.com/ defaults: run: working-directory: deployment