-
Notifications
You must be signed in to change notification settings - Fork 81
150 lines (135 loc) · 4.29 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: "ArgoCD: Scaledown"
on:
workflow_call:
inputs:
release_name:
required: true
type: string
template_name:
required: false
default: "adala"
type: string
cloud:
required: false
default: "aws"
type: string
cluster:
required: false
default: "dev.heartex.com"
type: string
namespace:
required: false
default: "prompt"
type: string
workflow_dispatch:
inputs:
release_name:
description: "Release name"
required: true
type: string
template_name:
description: "Template name"
required: false
default: "adala"
type: string
cloud:
description: "Cloud name"
required: false
default: "aws"
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
container:
image: "heartexlabs/actions-runner:master"
credentials:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: hmarr/debug-action@v3.0.0
- 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 = 'robot-ci-heartex@users.noreply.github.com';
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: Details
id: details
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:
release_name: "${{ inputs.release_name || steps.details.outputs.pretty_branch_name }}"
template_name: "${{ inputs.template_name || 'adala' }}"
cloud: "${{ inputs.cloud || 'aws' }}"
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: ${{ steps.argocd-app.outputs.app_name }}
desc: "Environment was scaled down"