-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (130 loc) · 4.78 KB
/
release.yml
File metadata and controls
132 lines (130 loc) · 4.78 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Build and push release image
on:
push:
branches:
- test
- prod
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build app and upload
run: |
echo "Building..."
echo "Build done!"
echo "Uploading..."
echo "Upload done!"
deploy-to-test:
needs: build
runs-on: ubuntu-latest # use self-hosted machines if your Bytebase runs in internal networks.
environment: test
env:
BYTEBASE_URL: https://demo.bytebase.com
BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com
BYTEBASE_PROJECT: "projects/project-sample"
BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test"
FILE_PATTERN: "migrations/*.sql"
if: github.ref == 'refs/heads/test'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Bytebase
id: login
uses: bytebase/login-action@v1
with:
bytebase-url: ${{ env.BYTEBASE_URL }}
service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }}
service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production.
- name: Create release
id: create-release
uses: bytebase/create-release-action@v1
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
file-pattern: ${{ env.FILE_PATTERN }}
# fail the action if release checks report any error.
check-release: "FAIL_ON_ERROR"
project: ${{ env.BYTEBASE_PROJECT }}
targets: ${{ env.BYTEBASE_TARGETS }}
validate-only: false
- name: Create plan
id: create-plan
uses: bytebase/create-plan-from-release-action@v1
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
project: ${{ env.BYTEBASE_PROJECT }}
release: ${{ steps.create-release.outputs.release }}
targets: ${{ env.BYTEBASE_TARGETS }}
check-plan: "SKIP"
- name: Rollout
id: rollout
uses: bytebase/rollout-action@v2
if: ${{ steps.create-plan.outputs.deployment-required == 'true' }}
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
plan: ${{ steps.create-plan.outputs.plan }}
target-stage: 'environments/test'
- name: Deploy app
run: |
echo "Deploying app to test environment..."
echo "Deploy app to test environment done!"
deploy-to-prod:
needs: build
runs-on: ubuntu-latest # use self-hosted machines if your Bytebase runs in internal networks.
environment: prod
env:
BYTEBASE_URL: https://demo.bytebase.com
BYTEBASE_SERVICE_ACCOUNT: ci@service.bytebase.com
BYTEBASE_PROJECT: "projects/project-sample"
BYTEBASE_TARGETS: "instances/prod-sample-instance/databases/hr_prod"
FILE_PATTERN: "migrations/*.sql"
if: github.ref == 'refs/heads/prod'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Bytebase
id: login
uses: bytebase/login-action@v1
with:
bytebase-url: ${{ env.BYTEBASE_URL }}
service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }}
service-secret: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}} # Please use secrets for sensitive data in production.
- name: Create release
id: create-release
uses: bytebase/create-release-action@v1
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
file-pattern: ${{ env.FILE_PATTERN }}
# fail the action if release checks report any error.
check-release: "FAIL_ON_ERROR"
project: ${{ env.BYTEBASE_PROJECT }}
targets: ${{ env.BYTEBASE_TARGETS }}
validate-only: false
- name: Create plan
id: create-plan
uses: bytebase/create-plan-from-release-action@v1
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
project: ${{ env.BYTEBASE_PROJECT }}
release: ${{ steps.create-release.outputs.release }}
targets: ${{ env.BYTEBASE_TARGETS }}
check-plan: "SKIP"
- name: Rollout
id: rollout
uses: bytebase/rollout-action@v2
if: ${{ steps.create-plan.outputs.deployment-required == 'true' }}
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
plan: ${{ steps.create-plan.outputs.plan }}
target-stage: 'environments/prod'
- name: Deploy app
run: |
echo "Deploying app to prod environment..."
echo "Deploy app to prod environment done!"