-
Notifications
You must be signed in to change notification settings - Fork 15
174 lines (163 loc) · 6.86 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Build Docker Image and Deploy
on:
push:
branches: [ main ]
paths-ignore:
- '.github/**'
- 'docs/**'
- '*.md'
release:
types: [ prereleased, released ]
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Build Start
id: ci_start
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL }}
text: "Build started 👀"
attachments:
- color: "dbab09"
fields:
- title: "Repository"
short: true
value: ${{ github.repository }}
- title: "Status"
short: true
value: "In Progress"
- title: "Branch"
short: true
value: ${{ github.ref }}
- title: "Author"
short: true
value: ${{ github.actor }}
- title: "Action"
value: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- title: "Diff"
value: ${{ github.event.head_commit.url }}
- title: "Changes"
value: ${{ toJSON(github.event.head_commit.message) }}
- name: Docker meta
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
# list of Docker images to use as base name for tags
images: |
crestal/intentkit
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
username: crestal
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
with:
build-args: |
RELEASE=${{ github.sha }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Configure AWS Credentials
if: ${{ github.event_name == 'release' }}
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ID }}:role/GithubActions
- name: Deploy to Amazon EKS Dev
if: ${{ github.event_name == 'release' && github.event.action == 'prereleased' }}
run: |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.EKS_DEV_CLUSTER }}
kubectl version
kubectl set image -n testnet-dev deployment/intent-api intent-api=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-autonomous intent-autonomous=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-twitter intent-twitter=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-tg intent-tg=crestal/intentkit:${{ github.event.release.tag_name }}
- name: Deploy to Amazon EKS Prod
if: ${{ github.event_name == 'release' && github.event.action == 'released' }}
run: |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.EKS_PROD_CLUSTER }}
kubectl version
kubectl set image -n testnet-prod deployment/intent-api intent-api=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-autonomous intent-autonomous=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-twitter intent-twitter=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-tg intent-tg=crestal/intentkit:${{ github.event.release.tag_name }}
- name: Build Success
if: ${{ success() }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d
with:
method: chat.update
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL }}
ts: "${{ steps.ci_start.outputs.ts }}"
text: "Build Succeeded ✅"
attachments:
- color: "28a745"
fields:
- title: "Repository"
short: true
value: ${{ github.repository }}
- title: "Status"
short: true
value: "Completed"
- title: "Branch"
short: true
value: ${{ github.ref }}
- title: "Author"
short: true
value: ${{ github.actor }}
- title: "Image"
value: https://hub.docker.com/r/crestal/intentkit/tags
- title: "Diff"
value: ${{ github.event.head_commit.url }}
- title: "Changes"
value: ${{ toJSON(github.event.head_commit.message) }}
- name: Build Failure
if: ${{ failure() }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d
with:
method: chat.update
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL }}
ts: "${{ steps.ci_start.outputs.ts }}"
text: "Build Failed ❌"
attachments:
- color: "dc3545"
fields:
- title: "Repository"
short: true
value: ${{ github.repository }}
- title: "Status"
short: true
value: "Failed"
- title: "Branch"
short: true
value: ${{ github.ref }}
- title: "Author"
short: true
value: ${{ github.actor }}
- title: "Action"
value: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- title: "Diff"
value: ${{ github.event.head_commit.url }}
- title: "Changes"
value: ${{ toJSON(github.event.head_commit.message) }}