Skip to content

start

start #1

Workflow file for this run

name: backend
on:
workflow_dispatch:
push:
paths:
- 'backend/**'
branches:
- main
tags:
- "v*.*.*"
pull_request:
paths:
- 'backend/**'
branches:
- main
env:
REDIS_HOST: redis
jobs:
build:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest black
- name: Run pytest
run: |
cd tests
# pytest
# - name: Check black
# run: black --check .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Tags
id: meta
uses: docker/metadata-action@v4
with:
images: multiparty/bwwc-backend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build & Push Docker image
uses: docker/build-push-action@v4
with:
context: ./backend
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update Staging Environment
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: fjogeleit/http-request-action@v1
with:
method: POST
url: ${{ secrets.PORTAINER_WEBHOOK_STAGING }}
preventFailureOnNoResponse: true
- name: Update Training Environment
if: startsWith(github.ref, 'refs/tags/v')
uses: fjogeleit/http-request-action@v1
with:
method: POST
url: ${{ secrets.PORTAINER_WEBHOOK_TRAINING }}
preventFailureOnNoResponse: true
- name: Update Production Environment
if: startsWith(github.ref, 'refs/tags/v')
uses: fjogeleit/http-request-action@v1
with:
method: POST
url: ${{ secrets.PORTAINER_WEBHOOK_PRODUCTION }}
preventFailureOnNoResponse: true