This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2.63 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
name: Release
on:
push:
branches:
- main
jobs:
release:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Restore cache
uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Run unit tests
run: make test
- name: Run integration tests
run: make e2e
- name: Set up env for build
run: |
echo "TAG=$(TZ=UTC date +%Y%m%d-%H%M%S)-$(echo ${{ github.sha }} | head -c7)" >> $GITHUB_ENV
- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build container image
run: docker build -t ghcr.io/${{ github.repository }}:$TAG .
- name: Push container image to registry
run: |
docker push ghcr.io/${{ github.repository }}:$TAG
docker tag ghcr.io/${{ github.repository }}:$TAG ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest
## Deploy using a custom workflow
- name: Run deploy workflow
env:
GH_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: gh workflow run "${{ secrets.DEPLOY_WORKFLOW }}" -R "${{ secrets.DEPLOY_WORKFLOW_REPO }}" -f tag="$TAG"
## Deploy to your DigitalOcean kubernetes cluster
#
# - name: Install doctl
# uses: digitalocean/action-doctl@v2
# with:
# token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# - name: Save kubeconfig
# run: doctl kubernetes cluster kubeconfig save --expiry-seconds 1200 ${{ secrets.DIGITALOCEAN_K8S_CLUSTER_NAME }}
# - name: Deploy to k8s
# run: kubectl set image deployment/$K8S_DEPLOYMENT_NAME $K8S_CONTAINER_NAME=ghcr.io/${{ github.repository }}:$TAG
# - name: Verify k8s deployment
# run: kubectl rollout status deployment/$K8S_DEPLOYMENT_NAME