forked from longhorn/bot
-
Notifications
You must be signed in to change notification settings - Fork 8
72 lines (60 loc) · 2.13 KB
/
build.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
name: Harvester Bot
on:
push:
branches:
- harvester
jobs:
build:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch Git tags
run: git fetch --tags
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
context: github-bot
file: github-bot/Dockerfile
push: true
tags: rancherlabs/harvester-github-bot:master
deploy:
needs: build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/kubectl/harvester/bot/credentials token | TOKEN ;
secret/data/github/repo/${{ github.repository }}/apiaddress/harvester/bot/credentials token | API_SERVER
- name: Install kubectl
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Restart Deployment
run: |
kubectl rollout restart deployment -n github-bot github-bot --token=$TOKEN --server=$API_SERVER --insecure-skip-tls-verify
env:
TOKEN: ${{ env.TOKEN }}
API_SERVER_ADDR: ${{ env.API_SERVER }}