-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 1.96 KB
/
on-push-to-main.yml
File metadata and controls
79 lines (67 loc) · 1.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
name: Main
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
#### Checks jobs/Lint, typecheck, test
checks:
name: Checks
uses: ./.github/workflows/checks.yml
secrets: inherit
#### Build and push image
build-and-push-image:
runs-on: ubuntu-latest
needs: checks
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: apps/backend/Dockerfile
build-args: |
APP_RELEASE=${{ github.sha }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy-to-dokploy:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Dokploy Deployment
run: |
curl -X 'POST' \
"${{ secrets.DOKPLOY_URL }}/api/trpc/application.deploy" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "x-api-key: ${{ secrets.DOKPLOY_AUTH_TOKEN }}" \
-d "{\"json\": {\"applicationId\": \"${{ secrets.DOKPLOY_APPLICATION_ID }}\"}}" \
-w "%{http_code}" \
-o /dev/null \
-s