-
Notifications
You must be signed in to change notification settings - Fork 40
90 lines (77 loc) · 2.76 KB
/
node.js.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
88
89
90
name: Node.js CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# TODO: see if we need to do anything special to cache docker images
- uses: c-hive/gha-npm-cache@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Tag Build
uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/${{ github.repository }}
# Only tag with latest if we're on main
tags: |
type=ref,event=pr
type=ref,event=branch
type=sha
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deployment:
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/feature/actions'
runs-on: ubuntu-latest
steps:
- name: Checkout to branch
uses: actions/checkout@v2
- name: Tag Build
uses: docker/metadata-action@v3
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha
- name: Create build context for k8s deployment
# There should only be 1 tag, so 'join' will just produce a simple string
run: |
touch k8s-context
echo IMAGE=${{ join(steps.meta.outputs.tags, '') }} > k8s-context
cat k8s-context
- name: Set up kubectl
uses: matootie/dokube@v1.4.0
with:
personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }}
clusterName: k8s-rf
- name: Deploy app
run: |
kubectl diff -k . || echo \n
kubectl delete secret reactibot-env || echo \n
kubectl create secret generic reactibot-env \
--from-literal=DISCORD_HASH=${{ secrets.DISCORD_HASH }} \
--from-literal=DISCORD_PUBLIC_KEY=${{ secrets.DISCORD_PUBLIC_KEY }} \
--from-literal=DISCORD_APP_ID=${{ secrets.DISCORD_APP_ID }} \
--from-literal=GUILD_ID=${{ secrets.GUILD_ID }} \
--from-literal=GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--from-literal=AMPLITUDE_KEY=${{ secrets.AMPLITUDE_KEY }} || echo \n
kubectl apply -k .