-
Notifications
You must be signed in to change notification settings - Fork 75
135 lines (120 loc) · 3.92 KB
/
argocd-scaledown.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
name: "ArgoCD: Scaledown"
on:
workflow_call:
inputs:
app_name:
required: true
type: string
template_name:
required: false
default: "label-studio-enterprise"
type: string
cluster:
required: false
default: "dev.heartex.com"
type: string
namespace:
required: false
default: "prompt"
type: string
workflow_dispatch:
inputs:
app_name:
description: "ArgoCD App name"
required: true
type: string
template_name:
description: "ArgoCD template name"
required: false
default: "label-studio-enterprise"
type: string
cluster:
description: "Cluster name"
required: false
default: "dev.heartex.com"
type: string
namespace:
description: "Namespace"
required: false
default: "prompt"
type: string
pull_request_target:
types:
- converted_to_draft
branches:
- master
- '**'
env:
INFRA_REPO: "HumanSignal/infra"
jobs:
scale:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]
- name: Get GitHub user details
id: get-github-user
uses: actions/github-script@v7
env:
ACTOR_USERNAME: ${{ github.event.sender.login }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const actor_username = process.env.ACTOR_USERNAME;
let user_name = 'robot-ci-heartex';
let user_email = '[email protected]';
try {
const {data: user} = await github.rest.users.getByUsername({
username: actor_username,
});
user_name = user.login;
user_email = user.email;
} catch (e) {
console.log(e)
}
core.setOutput('user_name', user_name);
core.setOutput('user_email', user_email);
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.INFRA_REPO }}
token: ${{ secrets.GIT_PAT }}
fetch-depth: 1
- name: Checkout Actions Hub
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_PAT }}
repository: HumanSignal/actions-hub
path: ./.github/actions-hub
- name: Git Configure
uses: ./.github/actions-hub/actions/git-configure
with:
username: "${{ steps.get-github-user.outputs.user_name }}"
email: "${{ steps.get-github-user.outputs.user_email }}"
- name: Calculate version
id: version
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref || github.ref_name }}
run: |
set -x
pretty_branch_name="$(echo -n "${BRANCH_NAME#refs/heads/}" | sed 's#/#-#g' | sed 's#_#-#g'| sed 's#\.#-#g' | tr '[:upper:]' '[:lower:]' | cut -c1-25)"
echo "pretty_branch_name=$pretty_branch_name" >> $GITHUB_OUTPUT
- name: Scaledown ArgoCD App
uses: ./.github/actions-hub/actions/argocd-app-scaledown
id: argocd-app
with:
app_name: "${{ inputs.app_name || steps.version.outputs.pretty_branch_name }}-${{ inputs.template_name || 'adala' }}"
cluster: "${{ inputs.cluster || 'dev.heartex.com' }}"
namespace: "${{ inputs.namespace || 'prompt' }}"
github_token: ${{ secrets.GIT_PAT }}
- name: Git Push
id: push
uses: ./.github/actions-hub/actions/git-push
- name: "GitHub deployment: Deactivate"
id: github-deployment-deactivate
uses: bobheadxi/deployments@v1
with:
step: deactivate-env
token: ${{ secrets.GIT_PAT }}
env: ${{ inputs.app_name || steps.version.outputs.pretty_branch_name }}
desc: "Environment was scaled down to 0"