-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (34 loc) · 1.49 KB
/
deploy.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
name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
env:
DISCORD_ID: ${{ vars.DISCORD_ID }}
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/setup-node@v4.0.0
with:
node-version-file: '.nvmrc'
- name: Install doctl
uses: digitalocean/action-doctl@v2.4.1
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Build container image
run: docker build -t ${{ secrets.REGISTRY_NAME }}/johannes:$(echo $GITHUB_SHA | head -c7) --build-arg DISCORD_ID=${{ env.DISCORD_ID }} .
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200
- name: Push image to DigitalOcean Container Registry
run: docker push ${{ secrets.REGISTRY_NAME }}/johannes:$(echo $GITHUB_SHA | head -c7)
- name: Update deployment file
run: TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|${{ secrets.REGISTRY_NAME }}/johannes:'${TAG}'|' $GITHUB_WORKSPACE/config/deployment.yml
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}
- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -f $GITHUB_WORKSPACE/config/deployment.yml
- name: Verify deployment
run: kubectl rollout status deployment/johannes