From 146dd77449a0efd02f75d5bc5e4c69c3583cea2b Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:09:04 +0200 Subject: [PATCH 1/6] The path can be relative or absolute under $GITHUB_WORKSPACE * README.md: * action.yml: * adrs/0153-checkout-v2.md: --- README.md | 14 +++++++++++++- action.yml | 2 +- adrs/0153-checkout-v2.md | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c56a6f..2143962 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous # Default: true persist-credentials: '' - # Relative path under $GITHUB_WORKSPACE to place the repository + # Relative or absolute path under $GITHUB_WORKSPACE to place the repository path: '' # Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching @@ -160,6 +160,18 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous path: my-tools ``` +## Checkout repo with a environment based path (side by side) + +```yaml +env: + main_path: ${{ github.workspace }}/main +steps: +- name: Checkout + uses: actions/checkout@v2 + with: + path: ${{ env.main_path }} +``` + ## Checkout multiple repos (nested) ```yaml diff --git a/action.yml b/action.yml index 91d3982..19ea55e 100644 --- a/action.yml +++ b/action.yml @@ -49,7 +49,7 @@ inputs: description: 'Whether to configure the token or SSH key with the local git config' default: true path: - description: 'Relative path under $GITHUB_WORKSPACE to place the repository' + description: 'Relative or absolute path under $GITHUB_WORKSPACE to place the repository' clean: description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching' default: true diff --git a/adrs/0153-checkout-v2.md b/adrs/0153-checkout-v2.md index 74730c7..ebe1f5f 100644 --- a/adrs/0153-checkout-v2.md +++ b/adrs/0153-checkout-v2.md @@ -65,7 +65,7 @@ We want to take this opportunity to make behavioral changes, from v1. This docum description: 'Whether to configure the token or SSH key with the local git config' default: true path: - description: 'Relative path under $GITHUB_WORKSPACE to place the repository' + description: 'Relative or absolute path under $GITHUB_WORKSPACE to place the repository' clean: description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching' default: true @@ -287,4 +287,4 @@ Note: - Update samples to consume `actions/checkout@v2` - Job containers now require git in the PATH for checkout, otherwise fallback to REST API - Minimum git version 2.18 -- Update problem matcher logic regarding source file verification (runner) \ No newline at end of file +- Update problem matcher logic regarding source file verification (runner) From e67ad3383bb9ed7870b02fae47b48ab0f5a151a1 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:11:07 +0200 Subject: [PATCH 2/6] Removed side by side * README.md: --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2143962..dbcba78 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous path: my-tools ``` -## Checkout repo with a environment based path (side by side) +## Checkout repo with a environment based path ```yaml env: From 4f92610a9793e6a300af7cce7417ebbace7f009f Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:18:55 +0200 Subject: [PATCH 3/6] Added environment based path test * __test__/verify-environment-path.sh: Added. * .github/workflows/test.yml: --- .github/workflows/test.yml | 12 ++++++++++++ __test__/verify-environment-path.sh | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100755 __test__/verify-environment-path.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87360d3..813b9cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,8 @@ on: jobs: build: runs-on: ubuntu-latest + env: + main_path: main_path_test steps: - uses: actions/setup-node@v1 with: @@ -57,6 +59,16 @@ jobs: shell: bash run: __test__/verify-clean.sh + # Use environment variable as path + - name: Environment path test + uses: ./ + with: + ref: test-data/v2/basic + path: ${{ env.main_path }} + - name: Verify environment path test + shell: bash + run: __test__/verify-environment-path.sh + # Side by side - name: Checkout side by side 1 uses: ./ diff --git a/__test__/verify-environment-path.sh b/__test__/verify-environment-path.sh new file mode 100755 index 0000000..bd64859 --- /dev/null +++ b/__test__/verify-environment-path.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ ! -f "./main_path_test/basic-file.txt" ]; then + echo "Expected file does not exist" + exit 1 +fi From 388793bd972dbe0d202b25fde9d1b8fcd1d49f23 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:25:15 +0200 Subject: [PATCH 4/6] Use ref as it should * .github/workflows/test.yml: --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 813b9cd..c1bfc66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: - name: Environment path test uses: ./ with: - ref: test-data/v2/basic + ref: test-data/v2/environment-path path: ${{ env.main_path }} - name: Verify environment path test shell: bash From d345e1892f7361d6f92f372f5ae70c5ca506b0bc Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:26:01 +0200 Subject: [PATCH 5/6] Back to basic * .github/workflows/test.yml: --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1bfc66..813b9cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: - name: Environment path test uses: ./ with: - ref: test-data/v2/environment-path + ref: test-data/v2/basic path: ${{ env.main_path }} - name: Verify environment path test shell: bash From d795c2780e79f41b814bf5dc36f864c846931d96 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 26 Aug 2020 12:44:28 +0200 Subject: [PATCH 6/6] Move env to test step * .github/workflows/test.yml: --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 813b9cd..a3e6424 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,6 @@ on: jobs: build: runs-on: ubuntu-latest - env: - main_path: main_path_test steps: - uses: actions/setup-node@v1 with: @@ -26,6 +24,8 @@ jobs: run: __test__/verify-no-unstaged-changes.sh test: + env: + main_path: main_path_test strategy: matrix: runs-on: [ubuntu-latest, macos-latest, windows-latest]