-
Notifications
You must be signed in to change notification settings - Fork 4
109 lines (107 loc) · 4.04 KB
/
release.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
name: Build and push release image
on:
push:
branches:
- main
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: [email protected]
BYTEBASE_PROJECT: "projects/project-sample"
# The Bytebase rollout pipeline will deploy to 'test' and 'prod' environments.
# 'deploy-to-test' job rollouts the 'test' stage and 'deploy-to-prod' job rollouts the 'prod' stage.
BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod"
FILE_PATTERN: "migrations/*.sql"
outputs:
bytebase-plan: ${{ steps.create-plan.outputs.plan }}
deployment-required: ${{ steps.create-plan.outputs.deployment-required }}
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 # the stage environment.
- name: Deploy app
run: |
echo "Deploying app to test environment..."
echo "Deploy app to test environment done!"
deploy_to_prod:
needs: deploy-to-test
runs-on: ubuntu-latest
environment: prod
env:
BYTEBASE_URL: https://demo.bytebase.com
BYTEBASE_SERVICE_ACCOUNT: [email protected]
if: ${{ needs.deploy-to-test.outputs.deployment-required == 'true' }}
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: Rollout
id: rollout
uses: bytebase/rollout-action@v2
with:
url: ${{ env.BYTEBASE_URL }}
token: ${{ steps.login.outputs.token }}
plan: ${{ needs.deploy-to-test.outputs.bytebase-plan }}
target-stage: environments/prod # the stage environment.
- name: Deploy app
run: |
echo "Deploying app to prod environment..."
echo "Deploy app to prod environment done!"