# GitHub Actions

This walkthrough shows you how to use CloudTruth parameters safely and securely with GitHub Actions using our [configure-action](https://github.com/marketplace/actions/cloudtruth-configure).

## Prerequisites

* You have a [GitHub account](https://github.com/join).
* You have created one or more [CloudTruth Parameters](https://docs.cloudtruth.com/configuration-management/parameters/parameter-management/managing-parameters).
* You have created a [CloudTruth API Access token](https://docs.cloudtruth.com/configuration-management/integrations/..#api-tokens).

## Update GitHub Repository Secrets

Adding your CloudTruth API access token as a GitHub secret allows GitHub Actions to reference the API token when running a workflow. This allows you to bring configuration and secrets from your CloudTruth projects into GitHub workflows.

In your GitHub repository settings, add a new repository secret with the name `CLOUDTRUTH_TOKEN` that contains your API access token as the value:

![Adding a Repository Secret](https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Fgit-blob-07078ef2a1717697890eb53f26a71d37e5afe453%2FGitHub%20Actions%20-%20Staging%20-%20Google%20Chrome.jpg?alt=media)

### Using [cloudtruth/configure-action](https://github.com/marketplace/actions/cloudtruth-configure)

The [action](https://github.com/marketplace/actions/cloudtruth-configure) can be used to inject the configuration and secrets from a project's environment into your GitHub workflow. Within the same job, steps following the action will have environment variables set to those in your project, based on the environment you choose:

```yaml
---
name: 'demo'
on:
  pull_request: {}

jobs:
  demo:
    runs-on: ubuntu-latest
    steps:
      - uses: cloudtruth/configure-action@v2.0.0
        with:
          apikey: "${{ secrets.CLOUDTRUTH_TOKEN }}"
          project: MyFirstProject
          environment: default
          
      - name: dump the environment
        run: |
          printenv | sort
```

GitHub Action [results](https://github.com/cloudtruth/configure-action/actions/workflows/demo.yml) will show the environment variables that were added to the job, and which parameters were redacted.

{% hint style="info" %}
The output below comes from the configure-action repository and shows a run from parameters that were pre-configured for the configure-action demo script - your output will match the parameters you created.
{% endhint %}

![Example workflow result](https://2952342643-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MGjN2Xg1mE8iTvg49dw%2Fuploads%2Fgit-blob-4dbce7b5a1592ced621e672baf09d486e49d3843%2Fimage%20\(86\).png?alt=media)

A complete example is found in the [demo workflow](https://github.com/cloudtruth/configure-action/blob/main/.github/workflows/demo.yml) of the configure-action repository.
