-
Notifications
You must be signed in to change notification settings - Fork 30
55 lines (50 loc) · 1.66 KB
/
deploy.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
name: Build & Deploy
on:
push:
branches:
- master
jobs:
build:
name: Build Binary
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image-tag.outputs.tag }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set image tag
id: image-tag
run: echo "tag=$(date -u '+%Y%m%d-%I%M%S')" >> $GITHUB_OUTPUT
- name: Build & Publish to Registry
uses: jerray/publish-docker-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
repository: ${{ secrets.DOCKER_NAME }}
build_args: GITHUB_SHA=${{ github.sha }}
tags: ${{ steps.image-tag.outputs.tag }}
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: Production
needs: build
steps:
- name: Deploy to server
uses: cross-the-world/ssh-pipeline@master
env:
DOCKER_NAME: ${{ secrets.DOCKER_NAME }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_TAG: ${{ needs.build.outputs.image_tag }}
with:
host: ${{ secrets.SSH_IP }}
user: ${{ secrets.SSH_NAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
connect_timeout: 10s
script: |
docker pull $DOCKER_NAME:$DOCKER_TAG
docker service update --image $DOCKER_NAME:$DOCKER_TAG nekobox_app
docker image prune -a -f