-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
74 lines (69 loc) · 2.49 KB
/
Copy pathaction.yml
File metadata and controls
74 lines (69 loc) · 2.49 KB
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
name: 'Setup PostgreSQL Preview Schema'
description: 'Sets up a PostgreSQL preview schema by cloning a base schema'
inputs:
deployment-name:
description: 'Name of the deployment (used for ConfigMap name)'
required: true
namespace:
description: 'Kubernetes namespace'
required: true
preview-number:
description: 'Preview number (PR number)'
required: true
secret-name:
description: 'Name of the secret containing DB password'
required: false
default: 'app-secrets'
postgres-image:
description: 'PostgreSQL image to use'
required: false
default: 'postgres:18'
base-schema:
description: 'Base schema to copy from'
required: false
default: 'main'
runs:
using: "composite"
steps:
- name: Prepare setup-schema job
env:
JOB_NAME: "prepare-schema-preview-${{ inputs.preview-number }}"
CONFIGMAP_NAME: "${{ inputs.deployment-name }}-environments"
SECRET_NAME: "${{ inputs.secret-name }}"
PREVIEW_SCHEMA_NAME: "preview_${{ inputs.preview-number }}"
POSTGRES_IMAGE: "${{ inputs.postgres-image }}"
BASE_SCHEMA: "${{ inputs.base-schema }}"
run: |
envsubst '
$JOB_NAME
$CONFIGMAP_NAME
$SECRET_NAME
$PREVIEW_SCHEMA_NAME
$POSTGRES_IMAGE
$BASE_SCHEMA
' < ${{ github.action_path }}/job-template.yml > job-setup-schema.yml
echo "Prepared job manifest: job-setup-schema.yml"
shell: bash
- name: Create setup-schema job
run: |
kubectl apply --namespace ${{ inputs.namespace }} -f job-setup-schema.yml
shell: bash
- name: Wait for setup-schema job to complete
env:
JOB_NAME: "prepare-schema-preview-${{ inputs.preview-number }}"
NAMESPACE: "${{ inputs.namespace }}"
run: |
echo "Waiting for job $JOB_NAME in namespace $NAMESPACE..."
if kubectl wait --namespace $NAMESPACE --for=condition=complete --timeout=60s job/$JOB_NAME; then
echo "Job finished with status: Complete"
kubectl logs job/$JOB_NAME --namespace $NAMESPACE
elif kubectl wait --namespace $NAMESPACE --for=condition=failed --timeout=1s job/$JOB_NAME; then
echo "Job finished with status: Failed"
kubectl logs job/$JOB_NAME --namespace $NAMESPACE
exit 1
else
echo "Timeout waiting for job to complete."
kubectl logs job/$JOB_NAME --namespace $NAMESPACE || true
exit 1
fi
shell: bash