-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (52 loc) · 2.07 KB
/
main.yaml
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
name: CI/CD
on:
push:
branches:
- main
jobs:
build_and_deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@main
- name: Building docker image
run: docker build ./Hakaton.SlobodaNemaCenu/ -t codeforacause/${{ secrets.UMBRACO_IMAGE_NAME }}:${{ github.run_number }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pushing Docker image to Docker hub
run: docker push codeforacause/${{ secrets.UMBRACO_IMAGE_NAME }}:${{ github.run_number }}
- name: Replace tokens
uses: cschleiden/replace-tokens@v1.1
with:
tokenPrefix: '#{'
tokenSuffix: '}#'
files: '["docker-compose.production.yaml"]'
env:
TAG_NUMBER: "${{ github.run_number }}"
DATABASE_PORT: "${{ secrets.DATABASE_PORT }}"
DATABASE_PASSWORD: "${{ secrets.DATABASE_PASSWORD }}"
UMBRACO_IMAGE_NAME: "${{ secrets.UMBRACO_IMAGE_NAME }}"
UMBRACO_PORT: "${{ secrets.UMBRACO_PORT }}"
ASPNETCORE_ENVIRONMENT: "${{ secrets.ASPNETCORE_ENVIRONMENT }}"
CONNECTION_STRING: "${{ secrets.CONNECTION_STRING }}"
- name: Copy docker compose file via SSH password
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
source: "docker-compose.production.yaml"
target: "~/Projects/slobodanemacenu/"
- name: Starting docker compose file via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: docker compose -f ~/Projects/slobodanemacenu/docker-compose.production.yaml up --build -d