From 032547798079c96edb40e86369824bf85db4048e Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 4 Jul 2023 19:23:09 +0700 Subject: [PATCH 1/2] feat: add `shell` action input --- .github/workflows/test.yml | 13 +++++++++++++ action.yml | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c719d16..2809eba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -132,3 +132,16 @@ jobs: build-args: --target test_c --target test_cpp run-test: true test-args: -R test + + specified-shell: + runs-on: windows-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3.5.3 + + - name: Use the action with specified shell + uses: ./ + with: + shell: bash + source-dir: test + run-build: true diff --git a/action.yml b/action.yml index e58ec81..0e02db2 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ branding: color: gray-dark icon: terminal inputs: + shell: + description: The shell to be used to run the commands + required: false source-dir: description: The source directory of the CMake project required: false @@ -57,6 +60,13 @@ runs: id: process-inputs shell: bash run: | + if [ -n '${{ inputs.shell }}' ]; then + SHELL='${{ inputs.shell }}' + else + SHELL='${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}' + fi + echo "shell=$SHELL" >> $GITHUB_OUTPUT + SOURCE_DIR="." if [ -n '${{ inputs.source-dir }}' ]; then SOURCE_DIR="${{ inputs.source-dir }}" @@ -121,15 +131,15 @@ runs: esac - name: Configure the CMake project - shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} + shell: ${{ steps.process-inputs.outputs.shell }} run: cmake ${{ steps.process-inputs.outputs.cmake-args }} - name: Build targets if: inputs.run-build != 'false' || inputs.run-test != 'false' - shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} + shell: ${{ steps.process-inputs.outputs.shell }} run: cmake ${{ steps.process-inputs.outputs.cmake-build-args }} - name: Run tests if: inputs.run-test != 'false' - shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} + shell: ${{ steps.process-inputs.outputs.shell }} run: ctest ${{ steps.process-inputs.outputs.cmake-test-args }} From ca8ab2ff60519a280dc00011ec59b75d23b848ae Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 4 Jul 2023 19:24:49 +0700 Subject: [PATCH 2/2] docs: add documentation of `shell` action input --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 667bb32..0901832 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action | Name | Value Type | Description | | --- | --- | --- | +| `shell` | String | The shell to be used to run the commands. It defaults to `pwsh` on Windows and `bash` on Linux and macOS. Refer to [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell) for more information on available shell options. | | `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. | | `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. | | `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |