-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (52 loc) · 1.84 KB
/
docker-workflow.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
name: Backend CI/CD
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Publish to output directory
run: dotnet publish -c Release -o ./output
- name: Build Docker image
run: docker build -t martian0x80/ipusenpai:latest .
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Push Docker image to registry
run: docker push martian0x80/ipusenpai:latest
deploy-to-server:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_KEY }}
port: ${{ secrets.REMOTE_PORT }}
script: |
echo "Pruning images..." | cowsay | lolcat
docker image prune
echo "Pulling Docker Image..." | cowsay | lolcat
docker pull martian0x80/ipusenpai:latest
echo "Killing em all..." | cowsay | lolcat
#docker rm $(docker stop $(docker ps -a -q --filter ancestor=martian0x80/ipusenpai --format="{{.ID}}"))
docker system prune -f
echo "Running Docker Container..." | cowsay | lolcat
#docker run -d -p 80:8080 --env-file ~/.env martian0x80/ipusenpai:latest
docker-compose up -d
echo "Pipeline completed." | cowsay | lolcat