-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 2.19 KB
/
deploy.yaml
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
name: Deploy Service
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy'
required: true
default: 'dev'
services:
description: 'Services to deploy (space seperated)'
required: true
jobs:
deployment:
runs-on: ubuntu-latest
name: Deploy ${{inputs.services}} in ${{inputs.environment}}
steps:
- name: Uppercase environment
run: |
echo "ENV=`echo ${{inputs.environment}} | tr '[:lower:]' '[:upper:]'`" >>${GITHUB_ENV}
- name: Set Default Values to Repository Variable
run: |
echo "ENABLE_FORCE_RECREATE=${{ vars.ENABLE_FORCE_RECREATE || 1 }}" >> ${GITHUB_ENV}
echo "DISABLE_REMOVE_ORPHANS=${{ vars.DISABLE_REMOVE_ORPHANS || 0 }}" >> ${GITHUB_ENV}
echo "DISABLE_ANSI=${{ vars.DISABLE_ANSI || 1 }}" >> ${GITHUB_ENV}
echo "ENABLE_GIT_PULL=${{ vars.ENABLE_GIT_PULL || 1 }}" >> ${GITHUB_ENV}
- name: call-webhook
run: |
if [ -z "${{ secrets[format('{0}_WEBHOOK_PASSWORD',env.ENV)] }}" ]; then
echo "::error::Secret '${{ format('{0}_WEBHOOK_PASSWORD',env.ENV) }}' is not set"
exit 1
fi
if [ -z "${{ secrets[format('{0}_WEBHOOK_URL',env.ENV)] }}" ]; then
echo "::error::Secret '${{ format('{0}_WEBHOOK_URL',env.ENV) }}' is not set"
exit 1
fi
if [ -z "${{ github.event.inputs.services }}" ]; then
echo "::error::'${{ github.event.inputs.services }}' is empty"
exit 1
fi
encoded_services=$(python3 -c "from urllib.parse import quote; print(quote('${{ github.event.inputs.services }}'))")
curl -X POST \
--fail-with-body -sS --no-buffer\
-H "Content-Type: application/json" \
-d '{"secret_token": "${{ secrets[format('{0}_WEBHOOK_PASSWORD',env.ENV)] }}", "ENABLE_FORCE_RECREATE":${{ env.ENABLE_FORCE_RECREATE }}, "DISABLE_REMOVE_ORPHANS":${{ env.DISABLE_REMOVE_ORPHANS }}, "DISABLE_ANSI":${{ env.DISABLE_ANSI }} ,"ENABLE_GIT_PULL":${{ env.ENABLE_GIT_PULL }}}' \
"${{ secrets[format('{0}_WEBHOOK_URL',env.ENV)] }}/hooks/deploy?services=$encoded_services"