-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (40 loc) · 1.42 KB
/
go.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
name: Go
on:
push:
branches:
- master
- dev
jobs:
build:
name: build and deploy
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v1
- name: 设置变量
run: |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "DOCKER_IMAGE_TAGS_LATEST=latest" >> $GITHUB_ENV
echo "DOCKER_IMAGE_TAGS_VERSION=$(cat version)" >> $GITHUB_ENV
echo "TZ=Asia/Shanghai" >> $GITHUB_ENV
- name: 构建镜像并推送
uses: docker/[email protected]
env:
TAG: ${{ github.sha }}
TZ: "Asia/Shanghai"
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ${{ secrets.DOCKER_REGISTRY }}
path: ./
repository: ${{ secrets.DOCKER_IMAGE_NAME }}
tags: ${{ env.DOCKER_IMAGE_TAGS_VERSION }},${{ env.GITHUB_SHA_SHORT }}
- name: 部署
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
docker service update --no-resolve-image --with-registry-auth --image ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.GITHUB_SHA_SHORT }} myapp_app_web