-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (58 loc) · 2.09 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
name: Build and Deploy
run-name: ${{ github.actor }} is building and deploying the app 🏗️
on:
push:
# 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
# So we need to put the condition in the if here
if: ${{ (github.actor == github.event.repository.owner.login) && (github.ref == 'refs/heads/master') }}
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.GITHUB_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.GITHUB_TOKEN }}"
deploy:
needs: build-musl
runs-on: ubuntu-latest
steps:
- name: Set secret as environment variable
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
run: echo "DISCORD_TOKEN=$DISCORD_TOKEN" >> $GITHUB_ENV
- name: Substitute secret in deployment YAML
run: |
envsubst < deployment.yaml > deployment_with_secret.yaml
- name: Deploy to Kubernetes
run: kubectl apply -f deployment_with_secret.yaml