From 26499cd2c593bdb0e5ec988fe9de5ef3f62a9169 Mon Sep 17 00:00:00 2001 From: sangyeong01 Date: Mon, 8 Dec 2025 18:36:12 +0900 Subject: [PATCH 1/4] fix: add username & groupname options Signed-off-by: sangyeong01 --- README.md | 12 ++++++++---- action.yml | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1d6485..0179f78 100644 --- a/README.md +++ b/README.md @@ -24,19 +24,20 @@ Copy files and directories between your local machine and a remote server in you ### Upload a file to a remote server ```yaml - name: Upload File - uses: alpacax/alpacon-cp-action@v1 + uses: alpacax/alpacon-cp-action@v1.0.1 with: workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }} api-token: ${{ secrets.ALPACON_API_TOKEN }} source: './data/file.txt' target-server: 'worker1' target-path: '/data/file.txt' + username: ubuntu ``` ### Download a file from a remote server ```yaml - name: Download File - uses: alpacax/alpacon-cp-action@v1 + uses: alpacax/alpacon-cp-action@v1.0.1 with: workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }} api-token: ${{ secrets.ALPACON_API_TOKEN }} @@ -44,12 +45,13 @@ Copy files and directories between your local machine and a remote server in you target-server: 'worker1' target-path: './data/' # Directory path - file will be saved as './data/file.txt' mode: download + username: ubuntu ``` ### Upload a directory recursively ```yaml - name: Upload Directory - uses: alpacax/alpacon-cp-action@v1 + uses: alpacax/alpacon-cp-action@v1.0.1 with: workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }} api-token: ${{ secrets.ALPACON_API_TOKEN }} @@ -57,12 +59,13 @@ Copy files and directories between your local machine and a remote server in you target-server: 'worker1' target-path: '/data/' recursive: true + username: ubuntu ``` ### Download a directory recursively ```yaml - name: Download Directory - uses: alpacax/alpacon-cp-action@v1 + uses: alpacax/alpacon-cp-action@v1.0.1 with: workspace-url: ${{ secrets.ALPACON_WORKSPACE_URL }} api-token: ${{ secrets.ALPACON_API_TOKEN }} @@ -71,6 +74,7 @@ Copy files and directories between your local machine and a remote server in you target-path: './data/' mode: download recursive: true + username: ubuntu ``` ## Inputs diff --git a/action.yml b/action.yml index 4405047..24e9406 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,12 @@ inputs: description: 'Set to true to copy directories recursively (-r option).' required: false default: 'false' + username: + description: 'Username to execute the command as (e.g., root, ubuntu).' + required: false + groupname: + description: 'Group name to execute the command as.' + required: false runs: using: "composite" @@ -39,10 +45,23 @@ runs: shell: bash - name: Execute CP run: | + # Validate groupname requires username + if [[ -z "${{ inputs.username }}" && -n "${{ inputs.groupname }}" ]]; then + echo "Error: groupname requires username to be specified" + exit 1 + fi + + # Build command with optional flags CP_CMD="alpacon cp" if [ "${{ inputs.recursive }}" = "true" ]; then CP_CMD="$CP_CMD -r" fi + if [[ -n "${{ inputs.username }}" && -n "${{ inputs.groupname }}" ]]; then + CP_CMD="$CP_CMD -u ${{ inputs.username }} -g ${{ inputs.groupname }}" + elif [[ -n "${{ inputs.username }}" ]]; then + CP_CMD="$CP_CMD -u ${{ inputs.username }}" + fi + if [ "${{ inputs.mode }}" = "download" ]; then $CP_CMD ${{ inputs.target-server }}:${{ inputs.source }} ${{ inputs.target-path }} else From 401fb18a0d29ba4572179350304291d99dd0dd77 Mon Sep 17 00:00:00 2001 From: Sangyeong Park <107484383+sangyeong01@users.noreply.github.com> Date: Mon, 8 Dec 2025 19:09:05 +0900 Subject: [PATCH 2/4] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0d3c223..49c9aae 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ This action requires the Alpacon CLI to be installed in your workflow. Use the [ | target-path | Destination path (remote for upload, local for download). | Yes | | mode | "upload" (default) or "download". | No | | recursive | Set to true to copy directories recursively. | No | +| username | Username for server authentication (optional). | No | +| groupname | Group name for server authentication (optional). | No | ## Notes From 30d92ef7a7c8d0c20b06754ccc10151b4ccb04a7 Mon Sep 17 00:00:00 2001 From: sangyeong01 Date: Mon, 8 Dec 2025 19:11:59 +0900 Subject: [PATCH 3/4] fix: add username test Signed-off-by: sangyeong01 --- .github/workflows/test.yml | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4a7fb7..d785847 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -83,4 +83,47 @@ jobs: source: './test-dir/' target-server: ${{ secrets.TEST_ALPACON_SERVER_NAME }} target-path: '/tmp/test-upload-dir/' - recursive: true \ No newline at end of file + recursive: true + + test-upload-with-username: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Alpacon CLI + uses: alpacax/alpacon-setup-action@v1.0.0 + + - name: Create test file + run: echo "Test content with username" > test-file-username.txt + + - name: Test File Upload with username + uses: ./ + with: + workspace-url: ${{ secrets.TEST_ALPACON_WORKSPACE_URL }} + api-token: ${{ secrets.TEST_ALPACON_API_TOKEN }} + source: './test-file-username.txt' + target-server: ${{ secrets.TEST_ALPACON_SERVER_NAME }} + target-path: '/tmp/test-upload-username.txt' + username: root + + - name: Test File Download with username + uses: ./ + with: + workspace-url: ${{ secrets.TEST_ALPACON_WORKSPACE_URL }} + api-token: ${{ secrets.TEST_ALPACON_API_TOKEN }} + source: '/tmp/test-upload-username.txt' + target-server: ${{ secrets.TEST_ALPACON_SERVER_NAME }} + target-path: './' + mode: download + username: root + + - name: Verify downloaded file + run: | + if [ -f "test-upload-username.txt" ]; then + echo "✅ File with username option downloaded successfully" + cat test-upload-username.txt + else + echo "❌ File download with username failed" + exit 1 + fi \ No newline at end of file From 18c73c207bda272d5a78cdf3a42d2bd0e70fd8f1 Mon Sep 17 00:00:00 2001 From: Eunyoung Jeong Date: Mon, 8 Dec 2025 21:26:59 +0900 Subject: [PATCH 4/4] Potential fix for code scanning alert no. 3: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d785847..b15f849 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,6 @@ name: Test Alpacon CP Action +permissions: + contents: read on: push: