Skip to content

Commit 8d47146

Browse files
committed
ci/cd: create deployment
1 parent 1ba56fc commit 8d47146

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/main.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
PROJECT_NAME: sfscon-backend
9+
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/sfscon-backend
10+
11+
jobs:
12+
deploy-test:
13+
runs-on: ubuntu-22.04
14+
if: github.ref == 'refs/heads/main'
15+
concurrency: deploy-test
16+
env:
17+
SERVER_PORT: 1005
18+
DOCKER_TAG: ${{ github.sha }}-test
19+
steps:
20+
- name: Checkout source code
21+
uses: actions/checkout@v4
22+
23+
- name: Create .env file
24+
uses: noi-techpark/github-actions/env-file@v2
25+
with:
26+
working-directory: ${{ env.WORKING_DIRECTORY }}
27+
env:
28+
X_SERVER_PORT: ${{ env.SERVER_PORT }}
29+
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
30+
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
31+
32+
- name: Build and push images
33+
uses: noi-techpark/github-actions/docker-build-and-push@v2
34+
with:
35+
working-directory: infrastructure
36+
docker-username: ${{ github.actor }}
37+
docker-password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Deploy application
40+
uses: noi-techpark/github-actions/docker-deploy@v2
41+
with:
42+
working-directory: infrastructure/ansible
43+
hosts: "test"
44+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
45+
docker-username: "noi-techpark-bot"
46+
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
47+
project-name: ${{ env.PROJECT_NAME }}
48+
49+
deploy-prod:
50+
runs-on: ubuntu-22.04
51+
if: github.ref == 'refs/heads/prod'
52+
# needs: test
53+
concurrency: deploy-prod
54+
env:
55+
SERVER_PORT: 1006
56+
DOCKER_TAG: ${{ github.sha }}
57+
steps:
58+
- name: Checkout source code
59+
uses: actions/checkout@v4
60+
61+
- name: Create .env file
62+
uses: noi-techpark/github-actions/env-file@v2
63+
with:
64+
working-directory: ${{ env.WORKING_DIRECTORY }}
65+
env:
66+
X_SERVER_PORT: ${{ env.SERVER_PORT }}
67+
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
68+
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}
69+
70+
- name: Build and push images
71+
uses: noi-techpark/github-actions/docker-build-and-push@v2
72+
with:
73+
working-directory: infrastructure
74+
docker-username: ${{ github.actor }}
75+
docker-password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Deploy application
78+
uses: noi-techpark/github-actions/docker-deploy@v2
79+
with:
80+
working-directory: infrastructure/ansible
81+
hosts: "test"
82+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
83+
docker-username: "noi-techpark-bot"
84+
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
85+
project-name: ${{ env.PROJECT_NAME }}

0 commit comments

Comments
 (0)