-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (53 loc) · 1.56 KB
/
action.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
64
65
66
67
name: publish
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: bitcoin-insights-frontend:latest
jobs:
build:
name: build angular app
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm install
- name: Build Angular App
run: npm run build --prod
publish:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Login to Docker Registry
run: |
echo ${{ secrets.PAT }} | docker login ghcr.io -u zurnov --password-stdin
- name: Build Docker Image
run: |
docker build . --tag ${{ env.REGISTRY }}/zurnov/${{ env.IMAGE_NAME }}
- name: Push Docker Image
run: |
docker push ${{ env.REGISTRY }}/zurnov/${{ env.IMAGE_NAME }}
deploy:
name: Deploy Docker Image
runs-on: ubuntu-latest
needs: publish
steps:
- name: install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
- name: connect and pull
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && docker compose pull && docker compose up -d"
- name: cleanup
run: rm -rf ~/.ssh