Skip to content
Merged
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
2 changes: 2 additions & 0 deletions docs/cli-deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ It performs a few steps to deploy:
5. Deploys the code to the cloud.
6. Registers the tasks as a new version in the environment (prod by default).

You can also setup [GitHub Actions](/github-actions) to deploy your tasks automatically.

## Options

### Environment `--env` or `-e`
Expand Down
53 changes: 53 additions & 0 deletions docs/deploy-environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,56 @@ return {
```

This should mean that for most secret services you won't need to convert the data into a different format.

### Using Google credential JSON files

Securely pass a Google credential JSON file to your Trigger.dev task using environment variables.

<Steps>

<Step title="Convert the Google credential file to base64">

In your terminal, run the following command and copy the resulting base64 string:

```
base64 path/to/your/service-account-file.json
```

</Step>

<Step title="Set up the environment variable in Trigger.dev">

Follow [these steps](/deploy-environment-variables) to set a new environment variable using the base64 string as the value.

```
GOOGLE_CREDENTIALS_BASE64="<your base64 string>"
```

</Step>

<Step title="Use the environment variable in your code">

Add the following code to your Trigger.dev task:

```ts
import { google } from 'googleapis';

const credentials = JSON.parse(Buffer.from(process.env.GOOGLE_CREDENTIALS_BASE64, 'base64').toString('utf8'));

const auth = new google.auth.GoogleAuth({
credentials,
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});

const client = await auth.getClient();
```

</Step>

<Step title="Use the client in your code">

You can now use the `client` object to make authenticated requests to Google APIs

</Step>

</Steps>
Loading
Loading