The type of the integration to run
| `true` | `""` | +| `identifier` |The identifier of the integration to run
| `false` | `""` | +| `port_client_id` |The Port client id
| `true` | `""` | +| `port_client_secret` |The Port client secret
| `true` | `""` | +| `initialize_port_resources` |Should ocean try to create the default blueprints, pages & integration config for the integration
| `false` | `true` | +| `config` |The configuration for the integration
| `false` | `""` | +| `platform` |The platform to run the integration on
| `false` | `linux/amd64` | +| `image` |The image to run the integration from
| `false` | `""` | +| `version` |The version of the integration to run
| `false` | `latest` | + + + +## Outputs + +| name | description | +| --- | --- | +| `exit_code` |The exit code of the Ocean Sail command
| + + +## Available integration types + +All available integration types are listed in the [Ocean integrations library](https://ocean.getport.io/integrations-library/) and can also be found in the data sources menu in the Port UI. + +## Example usage + +```yaml +- uses: ocean-github-action/sail@v1 + with: + type: 'jira' + port_client_id: ${{ secrets.PORT_CLIENT_ID }} + port_client_secret: ${{ secrets.PORT_CLIENT_SECRET }} + config: | + jira_host: ${{ secrets.JIRA_HOST }} + atlassian_user_email: ${{ secrets.ATLASSIAN_USER_EMAIL }} + atlassian_user_token: ${{ secrets.ATLASSIAN_USER_TOKEN }} +``` \ No newline at end of file diff --git a/sail/action.yml b/sail/action.yml new file mode 100644 index 0000000..52d06b9 --- /dev/null +++ b/sail/action.yml @@ -0,0 +1,89 @@ +name: '๐ Ocean Sail' +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 + 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.event_listener_type }}" ]] || { echo "inputs.event_listener_type 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 }}" >> .env + echo "OCEAN__PORT__CLIENT_SECRET=${{ inputs.port_client_secret }}" >> .env + + echo "OCEAN__EVENT_LISTENER={\"type\":\"ONCE\"}" >> .env + echo "OCEAN__INITIALIZE_PORT_RESOURCES=${{ inputs.initialize_port_resources }}" >> .env + + if [[ "${{ inputs.identifier }}" ]]; then + echo "OCEAN__INTEGRATION__IDENTIFIER=${{ inputs.identifier }}" >> .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}" >> .env + done + fi + + env >> .env + + docker run -i --rm --platform=${{ inputs.platform }} --env-file .env $image_name + + echo "exit_code=$?" >> $GITHUB_ENV + + - name: ๐งน Cleanup + if: always() + shell: bash + run: rm .env \ No newline at end of file diff --git a/sail/package.json b/sail/package.json new file mode 100644 index 0000000..af7d217 --- /dev/null +++ b/sail/package.json @@ -0,0 +1,9 @@ +{ + "name": "ocean-github-action-sail", + "version": "1.0.0", + "repository": "git@github.com:port-labs/ocean-github-action.git", + "author": "yair