-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (76 loc) · 2.77 KB
/
deploy-preview.yaml
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
name: Preview-Deploy
on:
pull_request: {}
env:
ENVIRONMENT: test
OPENSHIFT_API: https://api.cloudscale-lpg-2.appuio.cloud:6443
HELM_RELEASE_NAME: odootools-pr-${{ github.event.number }}
REGISTRY_URL: registry.cloudscale-lpg-2.appuio.cloud
IMG_TAG: pr-${{ github.event.number }}
NAMESPACE: vshn-odoo-test
jobs:
install:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
environment: preview
steps:
- uses: actions/checkout@v4
- name: Determine Go version from go.mod
run: echo "GO_VERSION=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup helmfile
uses: mamezou-tech/[email protected]
with:
helm-version: v3.7.1
helmfile-version: v0.142.0
install-kubectl: false
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_API }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
namespace: ${{ env.NAMESPACE }}
- name: Docker login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ github.repository_owner }}
password: ${{ secrets.OPENSHIFT_TOKEN }}
- name: Build and push image
run: make preview.push -e IMG_TAG=${{ env.IMG_TAG }}
- name: Deploy app
run: helmfile -f envs/helmfile.yaml -e ${{ env.ENVIRONMENT }} apply --wait
env:
HELM_RELEASE_NAME: ${{ env.HELM_RELEASE_NAME }}
IMG_TAG: ${{ env.IMG_TAG }}
GIT_SHA: ${{ github.event.pull_request.head.sha }}
ODOO_DB: ${{ secrets.ODOO_DB }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
- name: Gather status
run: |
echo "ROUTE_HOST=$(oc -n ${{ env.NAMESPACE }} get route ${{ env.HELM_RELEASE_NAME }} -o jsonpath='{.spec.host}')" >> $GITHUB_ENV
- name: Make comment in PR
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.number }}
body: |
## 🚀 Preview deployment active
| | |
|-|-|
**App URL** | https://${{ env.ROUTE_HOST }}
**Revision** | ${{ github.event.pull_request.head.sha }}
**Helm release** | ${{ env.NAMESPACE }}/${{ env.HELM_RELEASE_NAME }}
**Cluster** | ${{ env.OPENSHIFT_API }}
To uninstall this deployment, close or merge this PR.