-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (72 loc) · 2.44 KB
/
build.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
name: Build and Deploy
run-name: ${{ github.actor }} is building and deploying the app 🏗️
on:
push:
branches:
- main
# If we specify branches: [main] here it will run for any matching tags or push on branch main
tags: ['v[0-9].[0-9]+.[0-9]+']
workflow_dispatch:
permissions:
users:
- github.repository_owner
jobs:
build-musl:
runs-on: ubuntu-latest
steps:
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- uses: actions/checkout@v3
- run: rustup target add x86_64-unknown-linux-musl
- name: Install musl build tools
run: sudo apt update && sudo apt install musl-tools -y
- name: Cargo build
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/guilamb/interspecies-reviewer:latest
ghcr.io/guilamb/interspecies-reviewer:${{ github.run_number }}
secrets: |
"github_token=${{ secrets.REGISTRY_TOKEN }}"
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build-musl
steps:
- name: Set the Kubernetes context
uses: azure/k8s-set-context@v2
with:
method: service-account
k8s-url: ${{ secrets.SERVER_URL }}
k8s-secret: ${{ secrets.KUBERNETES_SECRET }}
- name: Checkout source code
uses: actions/checkout@v3
- name: Inject secret into manifest
run: awk -i inplace -v secret="${{ secrets.DISCORD_TOKEN }}" '{gsub("DISCORD_TOKEN_SECRET", secret)}1' kubernetes/deployment.yaml
- name: Deploy to the Kubernetes cluster
uses: azure/k8s-deploy@v1
with:
action: deploy
strategy: basic
namespace: interspecies-reviewer
manifests: |
kubernetes/deployment.yaml
images: |
ghcr.io/guilamb/interspecies-reviewer:latest
imagepullsecrets: |
github-container-registry