-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (108 loc) · 3.88 KB
/
publish.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Publish
on:
workflow_dispatch:
push:
tags:
- "v*"
branches:
- master
env:
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_READ_WRITE_USERNAME }}
password: ${{ secrets.GHCR_READ_WRITE_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
depoly-gz:
runs-on: ubuntu-latest
environment: gz
needs: build-and-push-image
if: ${{ needs.build-and-push-image.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}
depoly-sg:
runs-on: ubuntu-latest
environment: sg
needs: [depoly-gz, build-and-push-image]
if: ${{ needs.depoly-gz.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}
depoly-bj:
runs-on: ubuntu-latest
environment: bj
needs: [depoly-sg, build-and-push-image]
if: ${{ needs.depoly-sg.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}