Merge pull request #36 from toiki-org/feat/debug-config #12
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: Build & Deploy | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
build: | |
name: Build docker containers | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
with: | |
fetch-depth: 0 | |
- name: Paths filter | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
bot: | |
- 'bot/**' | |
server: | |
- 'server/**' | |
client: | |
- 'client/**' | |
nginx: | |
- 'nginx/**' | |
certbot: | |
- 'certbot/**' | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build toiki-build | |
if: steps.filter.outputs.client == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ghcr.io/toiki-org/toiki-build:latest | |
push: true | |
context: ./client | |
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-build:latest | |
cache-to: type=inline | |
build-args: | | |
ARCH=linux/amd64 | |
API_AUTHORITY=${{ secrets.API_AUTHORITY }} | |
- name: Build & Publish toiki-nginx | |
if: steps.filter.outputs.client == 'true' || steps.filter.outputs.nginx == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ghcr.io/toiki-org/toiki-nginx:latest | |
push: true | |
context: ./nginx | |
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-nginx:latest | |
cache-to: type=inline | |
- name: Build & Publish toiki-backend | |
if: steps.filter.outputs.server == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ghcr.io/toiki-org/toiki-backend:latest | |
push: true | |
context: ./server | |
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-backend:latest | |
cache-to: type=inline | |
- name: Build & Publish toiki-bot | |
if: steps.filter.outputs.bot == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ghcr.io/toiki-org/toiki-bot:latest | |
push: true | |
context: ./bot | |
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-bot:latest | |
cache-to: type=inline | |
- name: Build & Publish toiki-certbot | |
if: steps.filter.outputs.certbot == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ghcr.io/toiki-org/toiki-certbot:latest | |
push: true | |
context: ./certbot | |
cache-from: type=registry,ref=ghcr.io/toiki-org/toiki-certbot:latest | |
cache-to: type=inline | |
deploy: | |
needs: [build] | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git pull | |
uses: garygrossgarten/[email protected] | |
with: | |
command: cd toiki && git pull origin main | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.PRIVATE_KEY }} | |
- name: Docker compose up | |
uses: garygrossgarten/[email protected] | |
with: | |
command: cd toiki && docker-compose pull && docker-compose up --quiet-pull --force-recreate -d | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.PRIVATE_KEY }} | |
- name: Prune old docker images | |
uses: garygrossgarten/[email protected] | |
with: | |
command: cd toiki && docker system prune -a -f | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
privateKey: ${{ secrets.PRIVATE_KEY }} |