Skip to content

Commit

Permalink
fix(action): properly resolve cn path, closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog-crabnebula committed Oct 2, 2024
1 parent 4c63fcf commit 5ecb0dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-path-cwd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"action": patch
---

Properly resolve the `cn` path when using the `working-directory` option.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
- name: echo outputs
run: echo '${{ steps.version.outputs.stdout }}'

- name: get CLI version (cached)
- name: get CLI version (different cwd)
uses: ./
with:
command: --version
working-directory: .changes
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ runs:
# key: ${{ runner.os }}-${{ runner.arch }}-cn-${{ env.CURRENT_DATE }}

- name: Download CLI (Linux)
id: download-cn-cli
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
working-directory: ${{ inputs.path }}
Expand All @@ -54,8 +55,10 @@ runs:
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/linux-binary-aarch64 --output cn
fi
chmod +x cn
echo "cn-path=$(realpath cn)" >> $GITHUB_OUTPUT
- name: Download CLI (macOS)
id: download-cn-cli
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
working-directory: ${{ inputs.path }}
Expand All @@ -64,15 +67,18 @@ runs:
echo "Downloading CLI..."
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/darwin-binary-universal --output cn
chmod +x cn
echo "cn-path=$(realpath cn)" >> $GITHUB_OUTPUT
- name: Download CLI (Windows)
id: download-cn-cli
shell: bash
if: steps.restore-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
working-directory: ${{ inputs.path }}
run: |
: Download CLI
echo "Downloading CLI..."
curl -L https://cdn.crabnebula.app/download/crabnebula/cn-cli/latest/platform/windows-binary-x86_64 --output cn
echo "cn-path=$(realpath cn)" >> $GITHUB_OUTPUT
# - uses: actions/cache/save@v4
# continue-on-error: true
Expand All @@ -88,8 +94,9 @@ runs:
working-directory: ${{ inputs.working-directory }}
run: |
: cn ${{ inputs.command }}
echo "running `${{ steps.download-cn-cli.outputs.cn-path }}` from '${{ inputs.working-directory }}'"
exec 5>&1
OUTPUT=$(./"${{ inputs.path }}"/cn ${{ inputs.command }} | tee >(cat - >&5))
OUTPUT=$(${{ steps.download-cn-cli.outputs.cn-path }} ${{ inputs.command }} | tee >(cat - >&5))
echo "stdout<<nEOFn" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "nEOFn" >> $GITHUB_OUTPUT

0 comments on commit 5ecb0dc

Please sign in to comment.