Skip to content

Commit 5ec3301

Browse files
authored
Add parameters for version and token (#4)
1 parent 911afaf commit 5ec3301

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Testcontainers Cloud action
22

3-
This action downloads and run the agent. `TC_CLOUD_TOKEN` environment variable is required.
3+
This action downloads and runs the agent. Either `token` parameter or `TC_CLOUD_TOKEN` environment variable is required.
44

55
## Example usage
66

@@ -11,24 +11,25 @@ on:
1111
push:
1212
branches: [ main ]
1313

14-
permissions:
15-
contents: read
16-
1714
jobs:
1815
build:
1916
name: "Run checks"
2017
runs-on: ubuntu-18.04
2118
steps:
2219
- uses: actions/checkout@v3
23-
- name: Setup testcontainers-cloud
24-
uses: atomicjar/testcontainers-cloud-setup-action@main
25-
env:
26-
TC_CLOUD_TOKEN: ${{ secrets.TC_CLOUD_TOKEN }}
20+
2721

2822
- uses: actions/setup-java@v3
2923
with:
3024
java-version: '8.0.345'
3125
distribution: temurin
26+
27+
# Setup Testcontainers Cloud Client right before your Testcontainers tests
28+
- name: Setup Testcontainers Cloud Client
29+
uses: atomicjar/testcontainers-cloud-setup-action@v1
30+
with:
31+
token: ${{ secrets.TC_CLOUD_TOKEN }}
32+
3233
- name: Build with Maven
3334
run: mvn -V -B verify
3435
```

action.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
name: 'Testcontainers Cloud'
2-
description: 'Download and setup Testcontainers Cloud'
2+
description: 'Download and setup Testcontainers Cloud Client'
3+
inputs:
4+
version:
5+
description: 'Specific version of Testcontainers Cloud Client to use'
6+
required: false
7+
default: 'latest'
8+
token:
9+
description: 'Testcontainers Cloud API token'
10+
required: false
311
runs:
412
using: 'composite'
513
steps:
614
- id: testcontainers-cloud
715
shell: bash
16+
env:
17+
TC_CLOUD_TOKEN: ${{ inputs.token || env.TC_CLOUD_TOKEN }}
818
run: |
919
# determine the architecture of the platform
1020
suffix=$([[ $(uname -m) == "aarch64" || $(uname -m) == "arm64" ]] && echo "arm64" || echo "x86-64")
@@ -14,14 +24,20 @@ runs:
1424
1525
# determine the extension of the package
1626
extension=$([[ $os == "windows" ]] && echo ".exe" || echo "")
27+
28+
TCC_BINARY_NAME=${TCC_BINARY_NAME:-"tcc-agent"}
29+
30+
VERSION=${{ inputs.version }}
31+
32+
LATEST_BINARY_URL="https://app.testcontainers.cloud/download/testcontainers-cloud-agent_${VERSION}_${os}_${suffix}${extension}"
1733
1834
# fetch the latest TCC agent version and make it executable
19-
echo "Downloading https://app.testcontainers.cloud/download/testcontainers-cloud-agent_${os}_${suffix}${extension}"
20-
curl -L -o agent https://app.testcontainers.cloud/download/testcontainers-cloud-agent_${os}_${suffix}${extension}
21-
chmod +x agent
35+
echo "Downloading ${LATEST_BINARY_URL}"
36+
curl -fsSL -o "${TCC_BINARY_NAME}" "${LATEST_BINARY_URL}"
37+
chmod +x ${TCC_BINARY_NAME}
2238
2339
# start agent as background process
24-
./agent &
40+
./"${TCC_BINARY_NAME}" &
2541
2642
# make sure TCC is ready before proceeding
27-
./agent wait
43+
./"${TCC_BINARY_NAME}" wait

0 commit comments

Comments
 (0)