-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (59 loc) · 2.02 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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: CI / CD Pipeline
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
test:
runs-on: ubuntu-latest
environment: Test
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.4.x
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- name: Unit test
run: make test
- name: Starts the services as a dameon
run: make develop-daemon
- name: Run Cypress tests
uses: cypress-io/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_ADMIN_USER: ${{ secrets.CYPRESS_ADMIN_USER }}
CYPRESS_ADMIN_PASSWORD: ${{ secrets.CYPRESS_ADMIN_PASSWORD }}
- name: Stop the services
run: make develop-daemon-stop
deploy:
runs-on: ubuntu-latest
environment: Deploy
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup SSH environment
run: mkdir -p .secrets && echo "${{ secrets.SERVER_PRIVATE_KEY }}" > .secrets/labyrinth-ed25519.pem && chmod 0400 .secrets/labyrinth-ed25519.pem
- name: Setup deploy environment
run: echo 'SERVER_USER=${{ secrets.SERVER_USER }}' >> .secrets/.env && echo 'SERVER_HOSTNAME=${{ secrets.SERVER_HOSTNAME }}' >> .secrets/.env
- name: Test SSH Connection
run: make production-ssh-test
- name: Deploy to Production
run: make production-deploy