-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.33 KB
/
ci-cd.yml
File metadata and controls
79 lines (65 loc) · 2.33 KB
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
77
78
79
name: ci-cd.yml
on: push
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout to develop
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --production
- name: Build with PNPM
run: pnpm run build
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
if: github.ref == 'refs/heads/main'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Build and push by digest
if: github.ref == 'refs/heads/main'
id: build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
file: Dockerfile
context: .
publish:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') && github.ref == 'refs/heads/main' }}
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Add to Docker
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PALETTE_SSH_HOST }}
username: ${{ secrets.PALETTE_SSH_USERNAME }}
key: ${{ secrets.PALETTE_SSH_KEY }}
port: ${{ secrets.PALETTE_SSH_PORT }}
script: |
docker stop $(docker ps -aq -f 'ancestor=${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}')
docker rm $(docker ps -aq -f 'ancestor=${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}')
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
docker run -d -p 3336:3336 --name wstoio ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}