-
Notifications
You must be signed in to change notification settings - Fork 5
109 lines (93 loc) · 3.34 KB
/
Copy pathdeployment.yaml
File metadata and controls
109 lines (93 loc) · 3.34 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Deployment
on:
push:
branches: ['main']
paths:
- apps/client/**/*
- apps/server/**/*
- docker/**/*
- libraries/**/*
- scripts/**/*
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- .dockerignore
- .github/workflows/deployment.yaml
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
matrix:
component: ['client', 'server']
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Copy environment files
run: |
echo "${{ secrets.CLIENT_ENV }}" > apps/client/.env
echo "${{ secrets.SERVER_ENV }}" > apps/server/.env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5
- name: Log in to the Container registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.component }}
tags: type=sha,format=long
- name: Generate build information
id: build-info
run: |
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "build_time=$(date +'%Y-%m-%dT%H:%M:%S%:z')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf
with:
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_HASH=${{ steps.build-info.outputs.short_sha }}
BUILD_TIMESTAMP=${{ steps.build-info.outputs.build_time }}
secrets: |
posthog_cli_api_key=${{ secrets.POSTHOG_CLI_API_KEY }}
posthog_cli_project_id=${{ secrets.POSTHOG_CLI_PROJECT_ID }}
posthog_cli_host=${{ secrets.POSTHOG_CLI_HOST }}
context: .
file: docker/Dockerfile-${{ matrix.component }}
# platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
needs: ['build']
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Deploy stack to the server
uses: kitconcept/docker-stack-deploy@1a7a5e778d08cf92bda2ebbd068fe0ca078d09c8
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
remote_host: ${{ secrets.DEPLOY_SSH_HOST }}
remote_port: ${{ secrets.DEPLOY_SSH_PORT }}
remote_user: ${{ secrets.DEPLOY_SSH_USER }}
remote_private_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
stack_file: "docker/bus-tracker-stack.yaml"
stack_name: "bus-tracker"