ci: add GitHub Actions workflows
This commit is contained in:
86
.github/workflows/deploy.yaml
vendored
Normal file
86
.github/workflows/deploy.yaml
vendored
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
name: deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qa:
|
||||||
|
name: QA gates
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
COMPOSE_PROJECT_NAME: breadcrumb-ci
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create .env for CI
|
||||||
|
run: cp .env.example .env
|
||||||
|
|
||||||
|
- name: Start project services
|
||||||
|
run: |
|
||||||
|
docker compose up -d --force-recreate php db memcached
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: docker compose exec -T php composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
- name: Run required QA gates
|
||||||
|
run: bin/qa-required.sh
|
||||||
|
|
||||||
|
build-and-deploy:
|
||||||
|
name: Build & deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: qa
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build production image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--target prod \
|
||||||
|
-f docker/php/Dockerfile \
|
||||||
|
-t breadcrumb-the-shire:latest \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Export image to tar.gz
|
||||||
|
run: docker save breadcrumb-the-shire:latest | gzip > breadcrumb-the-shire.tar.gz
|
||||||
|
|
||||||
|
- name: Copy image to server
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
username: ${{ secrets.DEPLOY_USER }}
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
source: breadcrumb-the-shire.tar.gz
|
||||||
|
target: /root/dockerfiles-breadcrumb-infra/projects/
|
||||||
|
|
||||||
|
- name: Copy updated deploy files to server
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
username: ${{ secrets.DEPLOY_USER }}
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
source: "deploy/docker-compose.yml,deploy/nginx/"
|
||||||
|
target: /root/dockerfiles-breadcrumb-infra/projects/
|
||||||
|
strip_components: 1
|
||||||
|
|
||||||
|
- name: Deploy on server
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
username: ${{ secrets.DEPLOY_USER }}
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
set -e
|
||||||
|
cd /root/dockerfiles-breadcrumb-infra/projects
|
||||||
|
|
||||||
|
docker load < breadcrumb-the-shire.tar.gz
|
||||||
|
rm breadcrumb-the-shire.tar.gz
|
||||||
|
|
||||||
|
docker compose up -d --remove-orphans
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
docker compose exec -T php php bin/console module:sync
|
||||||
32
.github/workflows/qa-required.yaml
vendored
Normal file
32
.github/workflows/qa-required.yaml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: qa-required
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qa-required:
|
||||||
|
name: qa-required
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
COMPOSE_PROJECT_NAME: breadcrumb-ci
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create .env for CI
|
||||||
|
run: cp .env.example .env
|
||||||
|
|
||||||
|
- name: Start project services
|
||||||
|
run: |
|
||||||
|
docker compose up -d --force-recreate php db memcached
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: docker compose exec -T php composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
- name: Run required QA gates
|
||||||
|
run: bin/qa-required.sh
|
||||||
Reference in New Issue
Block a user