Skip to content

Commit

Permalink
fix: support absolute path for compose-file input
Browse files Browse the repository at this point in the history
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
  • Loading branch information
neilime committed Sep 20, 2024
1 parent ce6f83d commit 076990f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/__check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ jobs:
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
test-action-with-absolute-path:
runs-on: ubuntu-latest
name: Test with cwd
steps:
- uses: actions/checkout@v4

- name: Act
uses: ./
with:
compose-file: "${{ github.workspace }}/docker-compose.yml"
services: |
service-b
service-c
- name: "Assert: only expected services are running"
run: |
docker compose -f ./test/docker-compose.yml ps
docker compose -f ./test/docker-compose.yml ps | grep test-service-b-1 || (echo "Service service-b is not running" && exit 1)
docker compose -f ./test/docker-compose.yml ps | grep test-service-c-1 || (echo "Service service-c is not running" && exit 1)
(docker compose -f ./test/docker-compose.yml ps | grep test-service-a-1 && echo "Unexpected service service-a is running" && exit 1) || true
test-abort-on-container-exit:
runs-on: ubuntu-latest
name: Test with --abort-on-container-exit
Expand Down
12 changes: 8 additions & 4 deletions src/services/input.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ export class InputService {
private getComposeFiles(): string[] {
const cwd = this.getCwd();
const composeFiles = getMultilineInput(InputNames.ComposeFile).filter((composeFile: string) => {
if (!composeFile.length) {
if (!composeFile.trim().length) {
return false;
}

if (!existsSync(join(cwd, composeFile))) {
throw new Error(`${composeFile} does not exist in ${cwd}`);
if (existsSync(join(cwd, composeFile))) {
return true;
}

return true;
if (existsSync(composeFile)) {
return true;
}

throw new Error(`Compose file "${composeFile}" not found`);
});

if (!composeFiles.length) {
Expand Down

0 comments on commit 076990f

Please sign in to comment.