-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (104 loc) · 3.95 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
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
name: Deploy
on:
pull_request:
types: ["opened", "edited", "reopened", "synchronize"]
push:
branches:
- main
workflow_call:
# Map the workflow outputs to job outputs
outputs:
container_id:
description: "ID of your container inside your namespace"
value: ${{ jobs.deploy.outputs.scw_container_id }}
namespace_id:
description: "ID of your container namespace"
value: ${{ jobs.deploy.outputs.scw_namespace_id }}
jobs:
deploy:
runs-on: ubuntu-latest
name: deploy scaleway serverless container
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEPLOYMENT_NAME: "container"
SCW_DNS: ${{ github.ref_name == 'main' && 'containers.philibeaux.fr' || '' }}
steps:
- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ env.GH_TOKEN }}
env: ${{ env.DEPLOYMENT_NAME }}
ref: ${{ github.head_ref }}
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Export custom variables
run: |
SAFE_GITHUB_HEAD_REF_SLUG_URL=$(echo $GITHUB_HEAD_REF_SLUG_URL-$DEPLOYMENT_NAME | rev | cut -c-37 | rev)
([[ $GITHUB_REF == 'refs/heads/main' ]] && echo "BRANCH_SLUG=main" || echo "BRANCH_SLUG=$SAFE_GITHUB_HEAD_REF_SLUG_URL") >> $GITHUB_ENV
- name: Set scw_max_concurrency
id: set-max-concurrency
run: |
if [[ "${{ env.BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_MAX_CONCURRENCY=5" >> $GITHUB_ENV
else
echo "SCW_MAX_CONCURRENCY=1" >> $GITHUB_ENV
fi
- name: Set scw_min_scale
id: set-min-scale
run: |
if [[ "${{ env.BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_MIN_SCALE=1" >> $GITHUB_ENV
else
echo "SCW_MIN_SCALE=0" >> $GITHUB_ENV
fi
- name: Set scw_limit
id: set-cpu-limit
run: |
if [[ "${{ env.BRANCH_SLUG }}" == "main" ]]; then
echo "SCW_CPU_LIMIT=1120" >> $GITHUB_ENV
echo "SCW_MEMORY_LIMIT=1024" >> $GITHUB_ENV
else
echo "SCW_CPU_LIMIT=140" >> $GITHUB_ENV
echo "SCW_MEMORY_LIMIT=256" >> $GITHUB_ENV
fi
- name: Deploy Serverless Container Scaleway
uses: ./
id: deploy
with:
type: "deploy"
scw_registry: rg.fr-par.scw.cloud/aphilibeaux/scaleway-form:latest
scw_dns: ${{ env.SCW_DNS }}
root_zone: ${{ env.BRANCH_SLUG == 'main' }}
scw_access_key: ${{ secrets.SCW_ACCESS_KEY }}
scw_secret_key: ${{ secrets.SCW_SECRET_KEY }}
scw_containers_namespace_id: ${{ secrets.SCW_CONTAINERS_NAMESPACE_ID }}
scw_environment_variables: "GITHUB=DEPLOY"
# scw_secrets: "GITHUB=DEPLOY"
scw_min_scale: ${{ env.SCW_MIN_SCALE }}
scw_cpu_limit: ${{ env.SCW_CPU_LIMIT }}
scw_max_concurrency: ${{ env.SCW_MAX_CONCURRENCY }}
scw_sandbox: "v2"
scw_memory_limit: ${{ env.SCW_MEMORY_LIMIT }}
- name: check output
shell: bash
run: |
echo "${{ steps.deploy.outputs.url }}"
echo "${{ steps.deploy.outputs.container_url }}"
echo "${{ steps.deploy.outputs.scw_container_id }}"
echo "${{ steps.deploy.outputs.scw_namespace_id }}"
- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
env: ${{ env.DEPLOYMENT_NAME }}
token: ${{ secrets.GH_TOKEN }}
auto_inactive: true
# This will now be automatically handled by github with the auto_inactive
override: false
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.deploy.outputs.url }}