Skip to content

Force trigger

Force trigger #2

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- cicd
# paths:
# - "**/*.py"
# - "pyproject.toml"
# - "tests/**"
# - "features/**"
# - "Dockerfile"
# - "docker-compose.yml"
# - "production.env"
jobs:
test:
runs-on: ubuntu-latest
container:
image: python:3.9-slim
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
apt-get update && apt-get install -y curl && \
curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /github/home/.local/bin/poetry /usr/local/bin/poetry
- name: Configure Poetry
run: poetry config virtualenvs.create false && poetry install
- name: Run tests
run: PYTHONPATH=. pytest --cov=echopages -s tests
build:
runs-on: ubuntu-latest
needs: test
services:
docker:
image: docker:19.03.12
options: --privileged
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
run: echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
env:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
- name: Build and push Docker image
run: |
docker build -t pachovit/echopages:latest .
docker push pachovit/echopages:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Install SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Copy files to server
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
run: |
scp -o StrictHostKeyChecking=no docker-compose.yml $DEPLOY_USER@$DEPLOY_SERVER:/echopages/docker-compose.yml
scp -o StrictHostKeyChecking=no production.env $DEPLOY_USER@$DEPLOY_SERVER:/echopages/production.env
- name: Deploy to server
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }}
POSTMARK_SERVER_API_TOKEN: ${{ secrets.POSTMARK_SERVER_API_TOKEN }}
RECIPIENT_EMAIL: ${{ secrets.RECIPIENT_EMAIL }}
run: |
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_SERVER "
echo 'POSTMARK_SERVER_API_TOKEN=${{ secrets.POSTMARK_SERVER_API_TOKEN }}' >> /echopages/production.env;
echo 'RECIPIENT_EMAIL=${{ secrets.RECIPIENT_EMAIL }}' >> /echopages/production.env;
docker pull pachovit/echopages:latest;
docker compose -f /echopages/docker-compose.yml --env-file /echopages/production.env up -d;
"