Skip to content

Commit

Permalink
update due to new PaaS/CaaS version
Browse files Browse the repository at this point in the history
  • Loading branch information
hatamiarash7 committed Nov 9, 2023
1 parent b983a33 commit bd320f8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# ArvanCloud PaaS Action
# ArvanCloud PaaS/CaaS Action

![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/hatamiarash7/ar-paas-action?color=%2300baba&label=Marketplace&logo=github)

![logo](.github/logo.svg)

With this action you can update your deployment on ArvanCloud PaaS.
With this action you can update your deployment on ArvanCloud PaaS/CaaS.

## Usage

```yaml
- name: R1C PaaS Action
uses: hatamiarash7/ar-paas-action@v1.2.0
- name: R1C Action
uses: hatamiarash7/ar-paas-action@v1.3.0
with:
region: 1
auth: ${{ secrets.API_TOKEN }}
app: my-application
container: proxy
Expand All @@ -24,21 +25,31 @@ With this action you can update your deployment on ArvanCloud PaaS.

Following inputs can be used as `with` keys

| Name | Type | Default | Description |
| ----------- | -------- | ------- | ----------------------------------------------------------------------------------- |
| `auth` | Required | | Your API token from [ArvanCloud](https://www.arvancloud.com/en/docs/api) |
| `namespace` | | | The target namespace ( PaaS project ). Will be the default project if not specified |
| `app` | Required | | Application's name in your PaaS project |
| `container` | Required | | The container that you want to update its image |
| `image` | Required | | Docker image like `org/image:tag` |
| `version` | | `1.3.6` | Version of ArvanCloud CLI tool |
| Name | Type | Default | Description |
| ----------- | -------- | ------- | ------------------------------------------------------------------------------ |
| `region` | | `1` | Your Arvancloud Region |
| `auth` | Required | | Your API token |
| `namespace` | | | The target namespace ( project ). Will be the default project if not specified |
| `app` | Required | | Application's name in your PaaS project |
| `container` | Required | | The container that you want to update its image |
| `image` | Required | | Docker image like `org/image:tag` |
| `version` | | `1.3.6` | Version of ArvanCloud CLI tool |

### Region

We have 2 regions in ArvanCloud PaaS/CaaS for now:

- `1` for `ir-thr-ba1`
- `2` for `ir-thr-ba2`

### Authentication

You should get your API key from `ArvanCloud Dashboard > Settings > API keys ( Machine User )`. You need a key with **Container Service** permission.
You should get your API key from `ArvanCloud Dashboard > Settings > API keys`. You need a key with **Container Service** permission.

Define this key as a `Repository/Organization` secret.

Check [ArvanCloud Documentation](https://docs.arvancloud.ir/en/developer-tools/api/api-key) for more information.

---

## Support
Expand Down
19 changes: 12 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ branding:
icon: "cloud"
color: "blue"
inputs:
version:
description: "The version of CLI tool to use"
required: false
default: "1.3.6"
region:
description: "Your ArvanCloud Region"
required: false
default: "1"
auth:
description: "Your ArvanCloud API auth token"
required: true
namespace:
description: "The target namespace ( project )"
required: false
default: "default"
app:
description: "The ArvanCloud app to deploy to"
required: true
Expand All @@ -21,15 +25,16 @@ inputs:
image:
description: "Your new image to deploy"
required: true
version:
description: "The version of CLI tool to use"
namespace:
description: "The target namespace ( project )"
required: false
default: "1.3.6"
default: "default"
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.version }}
- ${{ inputs.region }}
- ${{ inputs.auth }}
- ${{ inputs.app }}
- ${{ inputs.container }}
Expand Down
28 changes: 18 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/bash

readonly CLI_VERSION="${1:?Error: Please set CLI version}"
readonly AUTH="${2:?Error: Please set your API token}"
readonly APP="${3:?Error: Please set your application name}"
readonly CONTAINER="${4:?Error: Please set your container name}"
readonly IMAGE="${5:?Error: Please set your image like this = image:tag}"
readonly REGION="${2:?Error: Please set region}"
readonly AUTH="${3:?Error: Please set your API token}"
readonly APP="${4:?Error: Please set your application name}"
readonly CONTAINER="${5:?Error: Please set your container name}"
readonly IMAGE="${6:?Error: Please set your image like this = image:tag}"

if [ "$6" != "default" ]; then
readonly NS="-n $6"
if [ "$7" != "default" ]; then
readonly NS="-n $7"
else
readonly NS=""
fi

print_header() {
printf "%s\n" "* * * * * * * * * * * * * * * * * * * * *"
printf "%s\n" "* *"
printf "%s\n" "* Welcome to ArvanCloud PaaS Action *"
printf "%s\n" "* ArvanCloud PaaS/CaaS Action *"
printf "%s\n" "* *"
printf "%s\n" "* * * * * * * * * * * * * * * * * * * * *"
printf "%s\n\n" ""
Expand Down Expand Up @@ -47,7 +48,7 @@ get_data() {
}

create_directory() {
printf " -----> Create directory\n"
printf " -----> Create service directory\n"
mkdir -p /service
}

Expand All @@ -58,7 +59,14 @@ download_cli_tool() {

login() {
printf " -----> Login\n"
echo "$AUTH" | /service/arvan login
printf "$AUTH\n"
{
sleep 2
echo -e "1\n"
sleep 2
echo "$AUTH"
sleep 0.1
} | /service/arvan login
}

deploy() {
Expand All @@ -68,7 +76,7 @@ deploy() {

cleanup() {
printf " -----> Cleanup\n"
rm -rf /root/.arvan
rm -rf /root/.arvan /service
}

main() {
Expand Down

0 comments on commit bd320f8

Please sign in to comment.