This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (70 loc) · 2.05 KB
/
ci-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
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
name: Continuous Integration
on:
pull_request:
branches:
- master
push:
branches:
- master
workflow_dispatch:
jobs:
ci:
name: Continuous Integration
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: yarn
- name: Lint
run: yarn lint
- name: Typecheck
run: yarn tsc
- name: Test
run: yarn test
- name: Build
run: yarn build
cd:
name: Continuous Deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
needs:
- ci
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
# - name: Build and push app to GitHub Container Registry
# uses: docker/build-push-action@v5
# with:
# file: Dockerfile
# push: true
# tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
- name: Set up Docker context
uses: amirmarmul/docker-context-ssh-action@v2
with:
ssh-host: ${{ secrets.SSH_HOST }}
ssh-username: ${{ secrets.SSH_USER }}
ssh-private-key: ${{ secrets.SSH_KEY }}
context-name: cloud
context-use: true
- name: Deploy application
env:
GHCR_USER: ${{ secrets.GHCR_TOKEN }}
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
COMPOSE_PROJECT_NAME: ${{ github.event.repository.name }}
run: |
docker-compose pull --quiet
docker-compose up --detach app