Skip to content

Commit 6889c5c

Browse files
Merge pull request #1 from crabnebula-dev/feat/action-enhancements
feat: Linux ARM64 support, print stdout
2 parents 151df22 + 970180c commit 6889c5c

2 files changed

Lines changed: 61 additions & 38 deletions

File tree

.github/workflows/test.yml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
11
name: Test Action
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
api-key:
7-
type: string
8-
description: Cloud API key
9-
required: true
10-
app-id:
11-
type: string
12-
description: Cloud application ID
13-
required: true
14-
cn-env:
15-
description: Cloud environment
16-
default: qa
17-
type: choice
18-
options:
19-
- qa
20-
- production
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/test.yml"
9+
- "action.yml"
2110

2211
concurrency:
2312
group: ${{ github.workflow }}-${{ github.ref }}
2413
cancel-in-progress: true
2514

26-
env:
27-
CN_API_KEY: ${{ inputs.api-key }}
28-
CN_APP_ID: ${{ inputs.app-id }}
29-
CN_ENV: ${{ inputs.cn-env }}
30-
3115
jobs:
3216
draft:
3317
strategy:
@@ -40,12 +24,16 @@ jobs:
4024
steps:
4125
- uses: actions/checkout@v4
4226

43-
- name: create draft release
27+
- name: get CLI version
4428
uses: ./
45-
id: draft
29+
id: version
4630
with:
47-
command: release draft ${{ env.CN_APP_ID }} 0.1.0
48-
api-key: ${{ env.CN_API_KEY }}
31+
command: --version
4932

5033
- name: echo outputs
51-
run: echo '${{ steps.draft.outputs.stdout }}'
34+
run: echo '${{ steps.version.outputs.stdout }}'
35+
36+
- name: get CLI version (cached)
37+
uses: ./
38+
with:
39+
command: --version

action.yml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ inputs:
88
description: 'API key with write permissions for CrabNebula Cloud'
99
required: true
1010
path:
11-
description: 'Optional path to run the CLI in, needs to be a valid directory path (Unix syntax)'
11+
description: 'Optional path to a directory where the CLI should be downloaded, needs to be a valid path (Unix syntax)'
12+
required: false
13+
default: '.'
14+
working-directory:
15+
description: 'Current working directory to use when running the CLI'
1216
required: false
1317
default: '.'
1418

@@ -20,30 +24,61 @@ outputs:
2024
runs:
2125
using: 'composite'
2226
steps:
23-
- name: Download CLI (unix)
27+
- name: Cache CLI
28+
id: restore-cache
29+
uses: actions/cache/restore@v4
30+
with:
31+
path: ${{ inputs.path }}/cn
32+
key: ${{ runner.os }}-${{ runner.arch }}-cn
33+
34+
- name: Download CLI (Linux)
2435
shell: bash
25-
if: runner.os == 'Linux' || runner.os == 'macOS'
36+
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
37+
working-directory: ${{ inputs.path }}
2638
run: |
27-
cd ${{ inputs.path }}
28-
curl -L https://cdn.crabnebula.app/download/01HKMY6ZXJA3P0QHA5GQY8KKRT/latest/cn_${{ runner.os == 'Linux' && 'linux' || 'macos' }} --output cn
39+
: Download CLI
40+
echo "Downloading CLI..."
41+
if [[ "${{ runner.arch }}" == "X64" ]]; then
42+
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-x86_64 --output cn
43+
else
44+
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-aarch64 --output cn
45+
fi
46+
chmod +x cn
47+
48+
- name: Download CLI (macOS)
49+
shell: bash
50+
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
51+
working-directory: ${{ inputs.path }}
52+
run: |
53+
: Download CLI
54+
echo "Downloading CLI..."
55+
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/darwin-binary-universal --output cn
2956
chmod +x cn
3057
3158
- name: Download CLI (Windows)
3259
shell: bash
33-
if: runner.os == 'Windows'
60+
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
61+
working-directory: ${{ inputs.path }}
3462
run: |
35-
cd ${{ inputs.path }}
36-
curl -L https://cdn.crabnebula.app/download/01HKMY6ZXJA3P0QHA5GQY8KKRT/latest/cn_windows.exe --output cn
63+
: Download CLI
64+
echo "Downloading CLI..."
65+
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/windows-binary-x86_64 --output cn
66+
67+
- uses: actions/cache/save@v4
68+
with:
69+
path: ${{ inputs.path }}/cn
70+
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
3771

3872
- name: "Run Command"
3973
id: run-command
4074
shell: bash
4175
env:
4276
CN_API_KEY: ${{ inputs.api-key }}
77+
working-directory: ${{ inputs.working-directory }}
4378
run: |
44-
cd ${{ inputs.path }}
45-
OUTPUT=$(./cn ${{ inputs.command }})
79+
: cn ${{ inputs.command }}
80+
exec 5>&1
81+
OUTPUT=$(./"${{ inputs.path }}"/cn ${{ inputs.command }} | tee >(cat - >&5))
4682
echo "stdout<<nEOFn" >> $GITHUB_OUTPUT
4783
echo "$OUTPUT" >> $GITHUB_OUTPUT
4884
echo "nEOFn" >> $GITHUB_OUTPUT
49-

0 commit comments

Comments
 (0)