This repository was archived by the owner on Sep 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 2.88 KB
/
release.yml
File metadata and controls
115 lines (97 loc) · 2.88 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
name: release
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
deploy:
environment: prod
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
KUBECONFIG: /tmp/kubeconfig
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
cache: false
- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Set up cache
uses: actions/cache@v3
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: lint-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
lint-${{ runner.os }}-go-
- name: Docker log in
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=edge,branch=main
type=sha
- name: Go build
env:
CGO_ENABLED: 0
run: go build -v ./cmd/testbot
- name: Image build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Get short commit SHA
id: var
shell: bash
run: |
echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: Generate deployment with SHA version
run: sed 's/:main/:sha-${{ steps.var.outputs.sha }}/g' .k8s/deployment.yml > .k8s/deployment.release.yml
- name: Set up kubectl cache
uses: actions/cache@v3
with:
path: /tmp/kubectl
key: kubectl-v1.26.3
- name: Check kubectl
id: "kubectl"
uses: andstor/file-existence-action@v2
with:
files: /tmp/kubectl
- name: Download kubectl
if: steps.kubectl.outputs.files_exists != 'true'
run: |
wget -O /tmp/kubectl "https://dl.k8s.io/release/v1.26.3/bin/linux/amd64/kubectl"
chmod +x /tmp/kubectl
- name: Setup kubeconfig
env:
KUBE: ${{ secrets.KUBE }}
run: .k8s/kubeconfig.sh
- name: Deploy
run: |
/tmp/kubectl apply -f .k8s/deployment.release.yml
/tmp/kubectl -n gotd-sandbox rollout status deployment/testbot