Skip to content

prod

prod #41

Workflow file for this run

name: prod
on:
workflow_dispatch
jobs:
deploy:
environment:
name: prod
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Config
env:
ENV_VALUES: ${{ secrets.ENV_VALUES }}
shell: bash
run: 'echo "$ENV_VALUES" > api/.env'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.REGISTRY_ACTOR }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push image to GitHub Container Registry
run: |
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --no-cache php
docker tag back-end_php:latest ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-php:latest
docker push ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-php:latest
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --no-cache caddy
docker tag back-end_caddy:latest ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-caddy:latest
docker push ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-caddy:latest
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /root/app
docker login --username ${{ secrets.REGISTRY_ACTOR }} --password ${{ secrets.REGISTRY_TOKEN }} ghcr.io
docker image pull ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-php:latest
docker image pull ${{ secrets.REGISTRY_DOCKER_REGISTRY }}/cobalt-caddy:latest
docker compose up --no-build --pull never --detach cobaltphp
docker compose up --no-build --pull never --detach cobaltcaddy