61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: Build and publish farmacia-bot images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build_images:
|
|
name: Build and push client's image to Gitea's registry
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to Gitea's docker registry
|
|
uses: docker/login-action@v3.1.0
|
|
with:
|
|
registry: ${{ vars.hostname_gitea }}
|
|
username: mozempk
|
|
password: ${{ secrets.REGISTRY_GITEA_TOKEN }}
|
|
|
|
- name: Extract app metadata (tags, labels) for Docker
|
|
id: meta_app
|
|
uses: docker/metadata-action@v5.5.1
|
|
with:
|
|
# this forces latest. Else it's created only if a release (tag) is created
|
|
tags: |
|
|
type=raw,enable=true,priority=200,prefix=,suffix=,value=latest
|
|
images: ${{ vars.hostname_gitea }}/${{gitea.repository}}
|
|
|
|
- name: Build and push app Docker image
|
|
id: push_app
|
|
uses: docker/build-push-action@v5.3.0
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta_app.outputs.tags }}
|
|
labels: ${{ steps.meta_app.outputs.labels }}
|
|
deploy_ovh:
|
|
runs-on: ubuntu-latest
|
|
needs: build_images
|
|
steps:
|
|
- name: Deploy to OVH
|
|
id: ovh_deploy
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USERNAME }}
|
|
key: ${{ secrets.DEPLOY_KEY }}
|
|
script: |
|
|
cd ~/stacks/bot-farmacia
|
|
docker-compose down && docker-compose pull && docker-compose up -d
|