-
Notifications
You must be signed in to change notification settings - Fork 6
50 lines (47 loc) · 1.58 KB
/
docker-image.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
name: Docker Image CI/CD
on:
push:
branches: [ "v3" ]
pull_request:
branches: [ "v3" ]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Alibaba Cloud Container Registry (ACR) Login
uses: aliyun/[email protected]
with:
login-server: https://registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push image
run: |
docker build -t ${{ secrets.DOCKER_REPOSITORY }}:latest .
docker push ${{ secrets.DOCKER_REPOSITORY }}:latest
pull-docker:
needs: [build]
name: Pull Docker
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.HOST_USERNAME }}
password: ${{ secrets.HOST_PASSWORD }}
port: ${{ secrets.HOST_PORT }}
script: |
sudo chmod 666 /var/run/docker.sock
docker stop $(docker ps -a -q) || true
docker rm $(docker ps -a -q) || true
docker rmi $(docker images -q) || true
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} registry.cn-hangzhou.aliyuncs.com
docker pull ${{ secrets.DOCKER_REPOSITORY }}:latest
docker run -p 3214:4000 -d ${{ secrets.DOCKER_REPOSITORY }}:latest