-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (54 loc) · 1.79 KB
/
cd.yml
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
name: CD
on:
push:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
matrix:
folders:
- infra/postgres
- infra/keycloak
- infra/nginx
- infra/promtail
- infra/loki
- infra/prometheus
- infra/grafana
- apps/api
- apps/ui
steps:
- uses: actions/checkout@v4
- name: Sets the folder and application names for the build
id: set-folder
run: |
echo "folder=$(dirname ${{ matrix.folders }})" >> $GITHUB_ENV
echo "app=$(basename ${{ matrix.folders }})" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
file: ./${{ env.folder }}/${{ env.app }}/Dockerfile
push: true
tags: ghcr.io/neumanf/mally-${{ env.app }}:latest
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Deploy
run: |
cd $HOME/mally &&
docker compose -f docker-compose.stack.yml pull &&
export $(cat .env) &&
docker stack deploy -c docker-compose.stack.yml mally