Coder Social home page Coder Social logo

sm-action's Introduction

Use Bitwarden Secrets in GitHub Actions

The Bitwarden sm-action repository contains the source code for the Secrets Manager GitHub Action.

Use the GitHub action, bitwarden/sm-action, to retrieve secrets from the Bitwarden Secrets Manager for use inside GitHub Actions.

The bitwarden/sm-action will add retrieved secrets as masked environment variables inside a given GitHub action.

Review GitHub's recommendations for security hardening GitHub Actions when using sensitive secrets.

Usage

To use the action, add a step to your GitHub workflow using the following syntax:

- name: Step name
  uses: bitwarden/sm-action@v1
  with:
    access_token: ${{ secrets.ACCESS_TOKEN }}
    secrets: |
      SECRET_ID > ENVIRONMENT_VARIABLE_NAME

Parameters

  • access_token

    The service account access token for retrieving secrets.

    Use GitHub's encrypted secrets to store and retrieve service account access tokens securely.

  • secrets

    One or more secret Ids to retrieve and the corresponding GitHub environment variable name to set.

    GitHub environment variables have stricter naming requirements than Bitwarden secrets.

    So the bitwarden/sm-action requires specifying an environment variable name for each secret retrieved in the following format:

    secrets: |
        SECRET_ID > ENVIRONMENT_VARIABLE_NAME
    

    Example

        secrets: |
            00000000-0000-0000-0000-000000000000 > TEST_EXAMPLE
    
  • cloud_region

    (Optional) For usage with the cloud-hosted services on either https://vault.bitwarden.com or https://vault.bitwarden.eu

    The default value will use us, which is the region for https://vault.bitwarden.com

    To use https://vault.bitwarden.eu, set the value to eu

  • base_url

    (Optional) For self-hosted bitwarden instances provide your https://your.domain.com

    If this optional parameter is provided the parameters identity_url and api_url are not required.

    The GitHub action will use BASE_URL/identity and BASE_URL/api for the identity and api endpoints.

  • identity_url

    (Optional) For self-hosted bitwarden instances provide your https://your.domain.com/identity

    The default value will use https://identity.bitwarden.com

  • api_url

    (Optional) For self-hosted bitwarden instances provide your https://your.domain.com/api

    The default value will use https://api.bitwarden.com

Examples

- name: Get Secrets
  uses: bitwarden/sm-action@v1
  with:
    access_token: ${{ secrets.ACCESS_TOKEN }}
    secrets: |
      00000000-0000-0000-0000-000000000000 > TEST_EXAMPLE
      bdbb16bc-0b9b-472e-99fa-af4101309076 > TEST_EXAMPLE_2

Environment variables created:

TEST_EXAMPLE: SECRET_VALUE_FOR_00000000-0000-0000-0000-000000000000
TEST_EXAMPLE_2: SECRET_VALUE_FOR_bdbb16bc-0b9b-472e-99fa-af4101309076

Example usage

- name: Get Secrets
  uses: bitwarden/sm-action@v1
  with:
    access_token: ${{ secrets.ACCESS_TOKEN }}
    cloud_region: eu
    secrets: |
      00000000-0000-0000-0000-000000000000 > TEST_EXAMPLE
- name: Use Secret
  run: example-command "$TEST_EXAMPLE"

Developing Bitwarden sm-action

Run Locally

Install the dependencies

$ npm install

Run formatter and lint

$ npm run prettier && npm run lint

Run the tests โœ”๏ธ

$ npm test

Prepare Source for Distribution

GitHub recommends using a tool called @vercel/ncc to compile code and modules into one file used for distribution.

  • Package the TypeScript for distribution
$ npm run bundle

sm-action's People

Contributors

renovate[bot] avatar michalchecinski avatar thomas-avery avatar hinton avatar kimdre avatar joseph-flinn avatar eeebru avatar tangowithfoxtrot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.