From a0fbcc2eb002435e2b62a8f416b33320375d7204 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Sat, 7 Jan 2023 11:39:03 +0700 Subject: [PATCH 1/3] add `build-dir` input --- action.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 16f98c2..be3c60a 100644 --- a/action.yml +++ b/action.yml @@ -9,14 +9,20 @@ inputs: description: The source directory of CMake project required: false default: . + build-dir: + description: The build directory of CMake project + required: false + default: build runs: using: composite steps: - name: Process inputs shell: bash run: | - CONFIGURE_ARGS="'${{ inputs.source-dir }}' -B build" + CONFIGURE_ARGS="'${{ inputs.source-dir }}' -B '${{ inputs.build-dir }}'" + BUILD_ARGS="--build '${{ inputs.build-dir }}'" echo "CMAKE_CONFIGURE_ARGS=$CONFIGURE_ARGS" >> $GITHUB_ENV + echo "CMAKE_BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV - name: Configure CMake shell: bash @@ -24,4 +30,4 @@ runs: - name: Build targets shell: bash - run: cmake --build build + run: cmake ${{ env.CMAKE_BUILD_ARGS }} From e580c4b6e5e10e1b14e876022bbe38c99319f7ee Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Sat, 7 Jan 2023 11:42:25 +0700 Subject: [PATCH 2/3] add workflow job to test this action with specified build dir --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16dba8b..f4b006b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,3 +31,18 @@ jobs: - name: Run build result run: ./build/hello_world + + use-action-with-specified-build-dir: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3.3.0 + + - name: Use this action with specified build directory + uses: ./ + with: + source-dir: test + build-dir: test/build + + - name: Run build result + run: test/build/hello_world From 82c154010f69d51d7f3d6a6a28976d84bf8f55db Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Sat, 7 Jan 2023 11:46:17 +0700 Subject: [PATCH 3/3] add workflow step to check if default build directory is not exist --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4b006b..a7daa46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,3 +46,6 @@ jobs: - name: Run build result run: test/build/hello_world + + - name: Check if default build directory is not exist + run: test ! -d build