-
Notifications
You must be signed in to change notification settings - Fork 9
executable file
·100 lines (91 loc) · 3.46 KB
/
gke-prod.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
name: Build and Deploy to GKE Prod
on:
workflow_dispatch:
release:
types: [released]
# Environment variables available to all jobs and steps in this workflow
env:
REGISTRY_HOSTNAME: gcr.io
GKE_PROJECT: console-labs-prod
IMAGE: consolelabs/mochi-discord
K8S_ENVIRONMENT: prod
SHA: ${{ github.sha }}
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v0"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v0"
- name: Setup Docker
run: |
gcloud auth configure-docker gcr.io
# Overwrite GITHUB_SHA
- name: Set SHA
if: github.event_name == 'workflow_dispatch'
run: |
echo "SHA=${GITHUB_SHA}-$(date +%Y%m%d%H%M%S)" >> "$GITHUB_ENV"
# Build & Push the Docker image
- name: Build & Push
run: |
docker build -t $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${GITHUB_REF_NAME} .
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${GITHUB_REF_NAME}
docker tag $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${GITHUB_REF_NAME} $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${SHA}
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${SHA}
# Setup kustomize
- name: Setup kustomize
run: |
curl -o kustomize --location https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
mv kustomize /tmp
- name: Checkout consolelabs/infrastructure
uses: actions/checkout@master
with:
repository: consolelabs/infrastructure
token: ${{ secrets.GH_PAT }}
path: ./infrastructure
ref: main
- name: Update discord version
run: |
cd ./infrastructure/mochi-discord/$K8S_ENVIRONMENT
git config user.name jphuc96
git config user.email [email protected]
/tmp/kustomize edit set image $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE=$REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${SHA}
cd ../v2
/tmp/kustomize edit set image $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE=$REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:${SHA}
git commit -am "[skip ci] mochi-discord ${K8S_ENVIRONMENT} image update"
git push origin main
notify:
name: Notify
needs: setup-build-publish-deploy
runs-on: ubuntu-latest
steps:
- name: Notify changelog
uses: fjogeleit/http-request-action@v1
if: github.event_name == 'release'
with:
url: "https://chglg.fly.dev/v1/changelog"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
timeout: 30000
escapeData: "true"
data: >-
{
"repo": "https://github.com/${{ github.repository }}",
"tag": "${{ github.ref }}",
"access_token": "${{ secrets.GH_PAT }}",
"app_name": "Discord",
"discord": {
"webhook": "${{ secrets.DISCORD_WEBHOOK }}",
"footer": {
"icon_url": "https://cdn.discordapp.com/emojis/1039475287169183744.webp?size=44&quality=lossless"
}
}
}