This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
165 lines (139 loc) · 4.2 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
on:
pull_request:
branches:
- main
types:
- closed
permissions:
contents: write
id-token: write
# Cancel any active builds when new commits are pushed
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test_and_push:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')
environment: Production
services:
postgres:
image: postgres:14.5
env:
POSTGRES_USER: tester
POSTGRES_PASSWORD: pgtestpw
POSTGRES_DB: l0_storage
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'zulu'
- name: Install CLI
uses: dopplerhq/cli-action@v2
- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install --yes postgresql-client
- name: Create Tables
run: psql -h localhost -d l0_storage -U tester -f database/create_tables.sql
env:
PGPASSWORD: pgtestpw
- name: Maven Package
run: doppler run -c tst -- mvn clean package
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_ST }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_PAT }}
- name: Registry login
run: doctl registry login --expiry-seconds 600
- name: Mvn project version
id: version
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: |
registry.digitalocean.com/tiki/l0-storage:${{ steps.version.outputs.version }}
registry.digitalocean.com/tiki/l0-storage:latest
build-args: |
JAR_FILE=target/*.jar
outputs:
version: ${{ steps.version.outputs.version }}
deploy_to_infra:
runs-on: ubuntu-latest
needs: [ test_and_push ]
environment: Production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform Variables
working-directory: ./infra
run: |-
cat > pipeline.auto.tfvars <<EOF
sem_ver = "${{ needs.bump_and_tag.outputs.version }}"
EOF
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Format
id: fmt
run: terraform fmt
working-directory: infra
- name: Terraform Init
id: init
run: terraform init
working-directory: infra
- name: Terraform Apply
id: apply
run: terraform apply -auto-approve
working-directory: infra
sentry_release:
runs-on: ubuntu-latest
needs: deploy_to_infra
environment: Production
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: 'my-tiki'
SENTRY_PROJECT: 'l0-storage'
with:
environment: public
ignore_missing: true
ignore_empty: true
publish_docs:
runs-on: ubuntu-latest
needs: [ sentry_release, test_and_push ]
environment: Production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: OpenApi
uses: readmeio/[email protected]
with:
rdme: openapi openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6379efc05c98fc002512b213
- name: Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.test_and_push.outputs.version }}