-
Notifications
You must be signed in to change notification settings - Fork 2
65 lines (57 loc) · 1.77 KB
/
Copy pathdeploy.yml
File metadata and controls
65 lines (57 loc) · 1.77 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
name: Build & Deploy site
on:
workflow_dispatch:
push:
branches:
- main
concurrency:
group: deploy
cancel-in-progress: false
jobs:
build-site:
name: Build & push image
runs-on: self-hosted
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitLab registry
uses: docker/login-action@v3
with:
registry: registry.primaverahq.com
username: ${{ secrets.GITLAB_REGISTRY_USER }}
password: ${{ secrets.GITLAB_REGISTRY_PASSWORD }}
- name: Build & push site image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
registry.primaverahq.com/mp/docs:${{ github.sha }}
registry.primaverahq.com/mp/docs:latest
deploy-site:
name: Deploy site on server
runs-on: self-hosted
needs: build-site
steps:
- name: Prepare SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy
chmod 600 ~/.ssh/deploy
printf "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
- name: Deploy site via SSH
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
REG_USER: ${{ secrets.GITLAB_REGISTRY_USER }}
REG_PASS: ${{ secrets.GITLAB_REGISTRY_PASSWORD }}
run: |
ssh -i ~/.ssh/deploy -o IdentitiesOnly=yes "$DEPLOY_USER@$DEPLOY_HOST" "
set -e
cd /var/www/docs
docker login -u '$REG_USER' -p '$REG_PASS' registry.primaverahq.com
docker compose pull docs
docker compose up -d docs
"