Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
dprosper committed Apr 10, 2022
1 parent 4493a33 commit 9056ffa
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Find Comment

A GitHub action to configure the IBM Cloud CLI and install plug-ins. It is usually used to integrate with your custom workflow or other IBM Cloud GitHub actions:

* [Create, Update and Delete to IBM Cloud Code Engine](https://github.com/dprosper/icce-cud-cli)

## Usage

```yml
- name: Configure IBM Cloud CLI
uses: dprosper/ic-setup-cli@v1
with:
API_KEY: ${{ secrets.API_KEY }}
INSTALL_PLUGINS: code-engine,container-service
REGION: eu-de
RESOURCE_GROUP: solutions
```
### Inputs
| Name | Description | Default |
| --- | --- | --- |
| `API_KEY` | API Key used for login. | |
| `INSTALL_PLUGINS` | Comma separated list of plug-ins to install. Obtain a list of available plug-ins in the [documentation](https://cloud.ibm.com/docs/cli). | |
| `REGION` | Name of region, such as 'us-south' or 'eu-gb'. | `us-east` |
| `RESOURCE_GROUP` | Resource Group Name or ID. | `default` |

> Note: Only the IBM Cloud official plug-in repository is supported in this action.

## Documentation

- [Examples](docs/examples.md)

## Versioning

For this action you can lock the version to use by specifying it like this: `dprosper/ic-setup-cli@v1`.

This action will always install the latest versions of the CLI and selected plug-ins. If you really need to, you can control the version of a plug-in used by specifing a specific version like this: `[email protected]`.

## License

[Apache Version 2.0](LICENSE)
57 changes: 57 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright © 2022 Dimitri Prosper <[email protected]>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Setup the IBM Cloud CLI
author: IBM

branding:
icon: 'terminal'
color: 'blue'
description: 'Setup CLI for IBM Cloud.'

inputs:
API_KEY:
description: IBM Cloud API key
required: true
REGION:
description: IBM Cloud Region
required: false
default: us-east
RESOURCE_GROUP:
description: IBM Cloud resource group
required: false
default: default
INSTALL_PLUGINS:
description: |-
List of plugins to install and separated by a comma to get a full list of available
Visit the Reference section on the https://cloud.ibm.com/docs/cli documentation page.
required: false

outputs:
url:
description: 'url of newly deployed app'
value: ${{ steps.icce.outputs.url }}

runs:
using: "composite"
steps:
- name: Run shell script to deploy the ibmcloud cli
id: ic-cli
run: ${{ github.action_path }}/ic-setup.sh
shell: bash
env:
API_KEY: ${{ inputs.API_KEY }}
REGION: ${{ inputs.REGION }}
RESOURCE_GROUP: ${{ inputs.RESOURCE_GROUP }}
INSTALL_PLUGINS: ${{ inputs.INSTALL_PLUGINS }}
4 changes: 4 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


* [Code Engine](./code-engine.md): An example workflow that uses GitHub Actions to deploy from source
code to [Code Engine](https://cloud.ibm.com/codeengine), a fully managed serverless platform.
45 changes: 45 additions & 0 deletions ic-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Copyright © 2022 Dimitri Prosper <[email protected]>

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail

curl -fsSL https://clis.cloud.ibm.com/install/linux | sh

plugins=$(echo "$INSTALL_PLUGINS" | tr "," "\n")
for plugin in $plugins; do
pluginversion=$(echo "$plugin" | tr "@" "\n")
pluginversion=(${pluginversion[@]})

if [ ${#pluginversion[@]} -eq 2 ]; then
set +o errexit
ibmcloud plugin install "${pluginversion[0]}" -v "${pluginversion[1]}"
[ $? -ne 0 ] && echo "Error in installing the $plugin plugin" && exit 1
set -o errexit
else
set +o errexit
ibmcloud plugin install "${pluginversion[0]}"
[ $? -ne 0 ] && echo "Error in installing the $plugin plugin" && exit 1
set -o errexit
fi

pluginversion=()
done

set +o errexit
ibmcloud login --apikey "$API_KEY" -r "$REGION" -g "$RESOURCE_GROUP"
[ $? -ne 0 ] && echo "Error during login" && exit 1
set -o errexit

exit 0

0 comments on commit 9056ffa

Please sign in to comment.