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

Add support for TCC_PROJECT_KEY and TCC_PROJECT_URL #7

Merged
merged 12 commits into from
Jul 20, 2023
29 changes: 28 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,31 @@ jobs:
with:
name: output-log-file
path: testcontainers-client.log
retention-days: 30
retention-days: 30

with-project-keys:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Testcontainers Cloud Client with project-key and project-url
uses: ./
with:
token: ${{ secrets.TC_CLOUD_TOKEN }}
project-key: testcontainers-cloud-setup-action-custom
project-url: https://testcontainers.cloud

with-project-keys-as-env-vars:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Testcontainers Cloud Client with project-key and project-url
uses: ./
with:
token: ${{ secrets.TC_CLOUD_TOKEN }}
env:
TCC_PROJECT_KEY: testcontainers-cloud-setup-action-custom-env-var
TCC_PROJECT_URL: https://testcontainers.cloud
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ jobs:
- `wait` (_optional_): `true` (default) /`false` - if action should wait until agent successfully connects to Testcontainers Cloud in advance
- `args` (_optional_): `string` - flags/arguments of the agent to pass as is. Consult with the knowledge base to find out more about possible options.
- `logfile` (_optional_): `string` - file to write the agent output instead of the standard out.
- `action` (_optional_): `prepare` (default) / `terminate` - action could be specified explicitly to terminate sessions eagerly.
- `action` (_optional_): `prepare` (default) / `terminate` - action could be specified explicitly to terminate sessions eagerly.
- `project-key` (_optional_): `GITHUB_REPOSITORY` (default) - project identifier
- `project-url` (_optional_): `GITHUB_SERVER_URL/GITHUB_REPOSITORY` (default) - project's url
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,41 @@ inputs:
description: 'What should be done exactly: prepare|terminate'
required: false
default: prepare
project-key:
description: 'Project identifier'
required: false
project-url:
description: 'Project URL'
required: false
runs:
using: 'composite'
steps:
- id: testcontainers-cloud-env-vars
name: Preparing Testcontainers Cloud env vars
shell: bash
run: |
# prepare tcc env vars
projectKey="$GITHUB_REPOSITORY"

if [[ ! -z "$INPUT_PROJECT_KEY" ]]; then
projectKey="$INPUT_PROJECT_KEY"
elif [[ ! -z "$TCC_PROJECT_KEY" ]]; then
projectKey="$TCC_PROJECT_KEY"
fi

projectUrl="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"

if [[ ! -z "$INPUT_PROJECT_URL" ]]; then
projectUrl="$INPUT_PROJECT_URL"
elif [[ ! -z "$TCC_PROJECT_URL" ]]; then
projectUrl="$TCC_PROJECT_URL"
fi

echo "TCC_PROJECT_KEY=${projectKey}" >> $GITHUB_ENV
echo "TCC_PROJECT_URL=${projectUrl}" >> $GITHUB_ENV
env:
INPUT_PROJECT_KEY: ${{ inputs.project-key }}
INPUT_PROJECT_URL: ${{ inputs.project-url }}
- id: testcontainers-cloud
name: Download and run Testcontainers Cloud Client
shell: bash
Expand Down