-
Notifications
You must be signed in to change notification settings - Fork 24
92 lines (81 loc) · 2.96 KB
/
deploy-worker.yml
File metadata and controls
92 lines (81 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Deploy Worker
on:
push:
branches: [dev, main]
paths:
- 'src/**'
- 'client/**'
- 'Dockerfile'
- 'package.json'
- 'bun.lockb'
- 'docker-compose.yml'
- 'docker-compose.swarm.yml'
- 'docker-compose.worker.yml'
- '.github/workflows/deploy-worker.yml'
# Allow manual trigger with options
workflow_dispatch:
inputs:
no_cache:
description: 'Build without cache (fresh build)'
required: false
default: 'false'
type: boolean
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: biosagent
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Dev branch: tag as 'dev' and commit SHA
- name: Build and Push (dev)
if: github.ref == 'refs/heads/dev'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
biosagent/bios:dev
biosagent/bios:dev-${{ github.sha }}
no-cache: true
# Main branch: tag as 'latest' and commit SHA
- name: Build and Push (main)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
biosagent/bios:latest
biosagent/bios:${{ github.sha }}
no-cache: true
# Trigger dev webhook with specific image tag to avoid stale cache
- name: Trigger Portainer Webhook (dev)
if: github.ref == 'refs/heads/dev'
run: |
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL_DEV }}?tag=dev-${{ github.sha }}" -k --fail --silent --show-error
echo "Dev webhook triggered with tag: dev-${{ github.sha }}"
# Trigger production webhook with specific image tag to avoid stale cache
- name: Trigger Portainer Webhook (main)
if: github.ref == 'refs/heads/main'
run: |
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}?tag=${{ github.sha }}" -k --fail --silent --show-error
echo "Production webhook triggered with tag: ${{ github.sha }}"
- name: Summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
echo "- **Image:** biosagent/bios:dev-${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Environment:** Development" >> $GITHUB_STEP_SUMMARY
else
echo "- **Image:** biosagent/bios:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Environment:** Production" >> $GITHUB_STEP_SUMMARY
fi