47 lines
1.3 KiB
YAML
47 lines
1.3 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
REGISTRY: gitea.local # Update this to your real Gitea domain
|
|
IMAGE_NAME: ${{ gitea.repository }}
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Build and push backend image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: ./backend
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend:latest
|
|
|
|
- name: Build and push frontend image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:latest
|
|
|
|
- name: Trigger Portainer Webhook (Deploy)
|
|
run: |
|
|
if [ -n "${{ secrets.PORTAINER_WEBHOOK_URL }}" ]; then
|
|
echo "Triggering Portainer Webhook..."
|
|
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
|
|
else
|
|
echo "No webhook URL found. Skipping auto-deploy. (You can deploy manually in Portainer)"
|
|
fi |