forked from mapasculturais/mapasculturais
-
Notifications
You must be signed in to change notification settings - Fork 6
138 lines (119 loc) · 4.26 KB
/
release.yml
File metadata and controls
138 lines (119 loc) · 4.26 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
133
134
135
136
137
138
name: Release
on:
push:
tags:
- "v*"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
target: production
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
- name: Extract version
id: version
run: |
VERSION=${{ github.ref_name }}
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
- name: Checkout GitOps repo
uses: actions/checkout@v4
with:
repository: lpirola/gitops-caicara-dev
token: ${{ secrets.GITOPS_TOKEN }}
path: gitops
- name: Update GitOps values.yaml
run: |
IMAGE_TAG="${{ steps.version.outputs.tag }}"
sed -i "s/tag: .*/tag: ${IMAGE_TAG}/" gitops/clusters/production/applications/mapas/values.yaml
git -C gitops diff clusters/production/applications/mapas/values.yaml
git -C gitops config user.name "github-actions[bot]"
git -C gitops config user.email "github-actions[bot]@users.noreply.github.com"
git -C gitops add clusters/production/applications/mapas/values.yaml
git -C gitops commit -m "chore: update mapas image to ${IMAGE_TAG}"
git -C gitops push
helm-test:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: "v3.16.0"
- name: Create kind cluster
uses: helm/kind-action@v1.10.0
with:
cluster_name: mapas-test
config: .github/kind-config.yaml
- name: Load Docker image into kind
run: |
IMAGE_TAG="${{ github.ref_name }}"
REPO="${{ github.repository }}"
REPO_LOWER=$(echo "$REPO" | tr '[:upper:]' '[:lower:]')
docker pull ghcr.io/${REPO_LOWER}:${IMAGE_TAG}
kind load docker-image ghcr.io/${REPO_LOWER}:${IMAGE_TAG} --name mapas-test
- name: Add helm repositories
run: helm repo add groundhog2k https://groundhog2k.github.io/helm-charts/
- name: Build helm chart dependencies
run: helm dependency build helm/mapas
- name: Install helm chart
run: |
IMAGE_TAG="${{ github.ref_name }}"
REPO="${{ github.repository }}"
REPO_LOWER=$(echo "$REPO" | tr '[:upper:]' '[:lower:]')
helm install mapas helm/mapas \
--namespace mapas-test \
--create-namespace \
--set image.repository=ghcr.io/${REPO_LOWER} \
--set image.tag=${IMAGE_TAG} \
--set postgresql.enabled=true \
--set 'redis-cache.enabled=false' \
--set 'redis-sessions.enabled=false' \
--set mapas.appEnv=development \
--set mapas.appDebug=true \
--set-json mapas.extraEnv='[{"name":"MAPASCULTURAIS_SKIP_DB_INIT","value":"true"}]' \
--wait \
--timeout 5m
- name: Verify deployment
run: |
kubectl get pods -n mapas-test
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=mapas -n mapas-test --timeout 2m