Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The path can be relative or absolute under $GITHUB_WORKSPACE #340

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,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]
Expand Down Expand Up @@ -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: ./
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
# 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
Expand Down Expand Up @@ -152,6 +152,18 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
path: my-tools
```

## Checkout repo with a environment based path

```yaml
env:
main_path: ${{ github.workspace }}/main
steps:
- name: Checkout
uses: actions/checkout@v2
with:
jwillemsen marked this conversation as resolved.
Show resolved Hide resolved
path: ${{ env.main_path }}
```

## Checkout multiple repos (nested)

```yaml
Expand Down
6 changes: 6 additions & 0 deletions __test__/verify-environment-path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

if [ ! -f "./main_path_test/basic-file.txt" ]; then
echo "Expected file does not exist"
exit 1
fi
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions adrs/0153-checkout-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
- Update problem matcher logic regarding source file verification (runner)