-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (46 loc) · 1.68 KB
/
client__depoly-production.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
name: (get-p-client) Deploy On Production Server
on:
pull_request:
branches:
- main
types:
- closed
workflow_dispatch:
env:
DOCKER_IMAGE_TAG: ${{secrets.DOCKER_USERNAME}}/get-p-frontend:latest
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Code Checkout
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
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Build and Push to DockerHub
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{env.DOCKER_IMAGE_TAG}}
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Stop Running Container and Remove Images
run: |
sudo docker stop get-p-frontend || true
sudo docker rm get-p-frontend || true
sudo docker rmi ${{env.DOCKER_IMAGE_TAG}} || true
- name: Pull Docker Image from Dockerhub
run: sudo docker pull ${{env.DOCKER_IMAGE_TAG}}
- name: Run Container
run: sudo docker run -d -p ${{secrets.FORWARDING_PORT}} --name get-p-frontend ${{env.DOCKER_IMAGE_TAG}}
- name: Prune Unused Containers and Images
run: sudo docker system prune -a -f