-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
62 lines (54 loc) · 2.33 KB
/
Copy pathaction.yml
File metadata and controls
62 lines (54 loc) · 2.33 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
name: 'Setup PostgreSQL Preview Schema'
description: 'Sets up a PostgreSQL preview schema by cloning the main 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'
runs:
using: "composite"
steps:
- name: Prepare setup-schema job
run: |
JOB_NAME="prepare-schema-preview-${{ inputs.preview-number }}"
CONFIGMAP_NAME="${{ inputs.deployment-name }}-environments"
# Create a temporary file for the manifest
cp ${{ github.action_path }}/job-template.yml job-setup-schema.yml
# Replace placeholders
sed -i "s/JOB_NAME_PLACEHOLDER/$JOB_NAME/g" job-setup-schema.yml
sed -i "s/CONFIGMAP_NAME_PLACEHOLDER/$CONFIGMAP_NAME/g" job-setup-schema.yml
sed -i "s/SECRET_NAME_PLACEHOLDER/${{ inputs.secret-name }}/g" job-setup-schema.yml
sed -i "s/PREVIEW_NUMBER_PLACEHOLDER/${{ inputs.preview-number }}/g" 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
run: |
JOB_NAME="prepare-schema-preview-${{ inputs.preview-number }}"
NAMESPACE="${{ inputs.namespace }}"
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