-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
96 lines (86 loc) · 3.46 KB
/
action.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
name: '🌊 Ocean Sail'
branding:
icon: 'anchor'
color: 'blue'
description: 'Runs the Ocean Sail command for a specific type of integration'
inputs:
type:
description: 'The type of the integration to run'
required: true
identifier:
description: 'The identifier of the integration to run'
required: false
port_client_id:
description: 'The Port client id'
required: true
port_client_secret:
description: 'The Port client secret'
required: true
port_base_url:
description: 'The Port base URL'
default: 'https://api.getport.io'
required: false
initialize_port_resources:
description: 'Should Ocean try to create the default resources (blueprints, pages, integration config, etc.) provided with the integration'
required: false
default: 'true'
config:
description: 'The configuration for the integration'
required: false
# Misc inputs
platform:
description: 'The platform to run the integration on'
required: false
default: 'linux/amd64'
image:
description: 'The image to run the integration from'
required: false
version:
description: 'The version of the integration to run'
required: false
default: 'latest'
outputs:
exit_code:
description: 'The exit code of the Ocean Sail command'
value: ${{ steps.ocean-sail.outputs.exit_code }}
runs:
using: 'composite'
steps:
- name: ✅ Validate inputs
shell: bash
run: |
[[ "${{ inputs.type }}" ]] || { echo "type input is empty" ; exit 1; }
[[ "${{ inputs.port_client_id }}" ]] || { echo "inputs.port_client_id input is empty" ; exit 1; }
[[ "${{ inputs.port_client_secret }}" ]] || { echo "inputs.port_client_secret input is empty" ; exit 1; }
[[ "${{ inputs.initialize_port_resources }}" ]] || { echo "inputs.initialize_port_resources input is empty" ; exit 1; }
[[ "${{ inputs.platform }}" ]] || { echo "inputs.platform input is empty" ; exit 1; }
[[ "${{ inputs.version }}" ]] || { echo "inputs.version input is empty" ; exit 1; }
- name: 🌊 Run Ocean Sail dockerized
shell: bash
run: |
image_name="ghcr.io/port-labs/port-ocean-${{ inputs.type }}:${{ inputs.version }}"
if [[ "${{ inputs.image }}" ]]; then
image_name="${{ inputs.image }}:${{ inputs.version }}"
fi
echo "OCEAN__PORT__CLIENT_ID=${{ inputs.port_client_id }}" >> .sail-env
echo "OCEAN__PORT__CLIENT_SECRET=${{ inputs.port_client_secret }}" >> .sail-env
echo "OCEAN__PORT__BASE_URL=${{ inputs.port_base_url }}" >> .sail-env
echo "OCEAN__EVENT_LISTENER={\"type\":\"ONCE\"}" >> .sail-env
echo "OCEAN__INITIALIZE_PORT_RESOURCES=${{ inputs.initialize_port_resources }}" >> .sail-env
if [[ "${{ inputs.identifier }}" ]]; then
echo "OCEAN__INTEGRATION__IDENTIFIER=${{ inputs.identifier }}" >> .sail-env
fi
if [[ "${{ inputs.config }}" ]]; then
for key in $(echo "${{ inputs.config }}" | yq eval "keys | .[]"); do
value=$(echo "${{ inputs.config }}" | yq eval ".$key")
upper_key=$(echo $key | tr '[:lower:]' '[:upper:]')
echo "OCEAN__INTEGRATION__CONFIG__${upper_key}=${value}" >> .sail-env
done
fi
env >> .sail-env
docker run -i --rm --platform=${{ inputs.platform }} --env-file .sail-env $image_name
echo "exit_code=$?" >> $GITHUB_ENV
- name: 🧹 Cleanup
if: always()
shell: bash
run: rm .sail-env