Skip to content

Commit

Permalink
feat: setup-s
Browse files Browse the repository at this point in the history
Signed-off-by: huyikun.hyk <[email protected]>
  • Loading branch information
huyikun.hyk committed Feb 26, 2024
1 parent 1e0fad3 commit 4509b92
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 19 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main", "v0.0.1" ]
branches: [ "main", "setup-s" ]
pull_request:
branches: [ "main", "v0.0.1" ]
branches: [ "main", "setup-s" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -34,9 +34,20 @@ jobs:

# Runs my action
- name: Setup serverless-devs
id: setup-serverless-devs
id: setup-s-aliyun
uses: ./
with:
provider: aliyun
account_id: MOCK_ACCOUNT_ID
access_key_id: MOCK_KEY_ID
access_key_secret: MOCK_KEY_SECRET
access: MOCK_ACCESS_ALIAS

- name: Setup serverless-devs
id: setup-s-tencent
uses: ./
with:
provider: tencent
account_id: MOCK_ACCOUNT_ID
access_key_id: MOCK_KEY_ID
access_key_secret: MOCK_KEY_SECRET
Expand Down
43 changes: 30 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
name: 'Setup Aliyun Serverless-Devs'
description: 'An Action for Setup Aliyun Serverless-Devs'
name: 'Setup for Serverless-Devs'
description: 'An Action for Setup Serverless-Devs and Different Provider's Authorization Config'
author: 'heimanba'
branding:
icon: 'heart'
color: 'red'

inputs:
account_id:
description: 'Aliyun Main Account ID'
required: true
access_key_id:
description: 'Aliyun Access Key ID'
required: true
access_key_secret:
description: 'Aliyun Access Key Secret'
provider:
description: 'Provider Name (aliyun/aws/tencent/huawei)'
required: true
default: 'aliyun'
access:
description: 'Access Alias Name'
required: true
default: 'default'
default: ${{ inputs.provider }}_access
account_id:
description: 'Main Account ID'
required: false
access_key_id:
description: 'Access Key ID'
required: false
access_key_secret:
description: 'Access Key Secret'
required: false
version:
description: 'Serverless-devs Version, 3.0.0 as default.'
required: false
Expand All @@ -27,5 +31,18 @@ inputs:
runs:
using: "composite"
steps:
- run: ./script.sh ${{ inputs.account_id }} ${{ inputs.access_key_id }} ${{ inputs.access_key_secret }} ${{ inputs.access }} ${{ inputs.version }}
shell: bash
- run: ./script.sh ${{inputs.provider}} ${{ inputs.version }} ${{ inputs.account_id }} ${{ inputs.access_key_id }} ${{ inputs.access_key_secret }} ${{ inputs.access }}
shell: bash
if: ${{ inputs.provider === 'aliyun' }}

- run: ./script.sh ${{inputs.provider}} ${{ inputs.version }} ${{ inputs.account_id }} ${{ inputs.access_key_id }} ${{ inputs.access_key_secret }} ${{ inputs.access }}
shell: bash
if: ${{ inputs.provider === 'aws' }}

- run: ./script.sh ${{inputs.provider}} ${{ inputs.version }} ${{ inputs.account_id }} ${{ inputs.access_key_id }} ${{ inputs.access_key_secret }} ${{ inputs.access }}
shell: bash
if: ${{ inputs.provider === 'tencent' }}

- run: ./script.sh ${{inputs.provider}} ${{ inputs.version }} ${{ inputs.account_id }} ${{ inputs.access_key_id }} ${{ inputs.access_key_secret }} ${{ inputs.access }}
shell: bash
if: ${{ inputs.provider === 'huawei' }}
13 changes: 10 additions & 3 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# 执行命令并捕获输出
VERSION_OUTPUT=$(s -v)
version=$5
version=$2
set -e # 报错后不继续执行

# 检查输出是否包含版本号的格式
Expand All @@ -11,13 +11,20 @@ if [[ $VERSION_OUTPUT ]]; then
echo "Version output is valid: $EXTRACTED_CONTENT"
else
echo 'Serverless-devs installing.'
curl "https://images.devsapp.cn/bin/s/${version}" --output /usr/local/bin/s
curl "https://images.devsapp.cn/bin/s/v${version}" --output /usr/local/bin/s
chmod 777 /usr/local/bin/s
echo 'Serverless-devs has been installed successfully.'
fi

echo '################################################'
s config add --AccountID $1 --AccessKeyID $2 --AccessKeySecret $3 -a $4 -f
if [[ $1 == "aliyun" ]]; then
s config add --AccountID $3 --AccessKeyID $4 --AccessKeySecret $5 -a $6 -f
elif [[ $1 == "aws" ]]; then
s config add --AccessKeyID $3 --SecretAccessKey $4 -a $5 -f
elif [[ $1 == "huawei" ]]; then
s config add --AccessKeyID $3 --SecretAccessKey $4 -a $5 -f
elif [[ $1 == "tencent" ]]; then
s config add --AccountID $3 --SecretID $4 --SecretKey $5 -a $6 -f
echo '################################################'
echo 'The access has been configured automatically, use "s config get" to check.'

Expand Down

0 comments on commit 4509b92

Please sign in to comment.