Skip to content

Github Actions

Jeff Felchner edited this page Sep 2, 2021 · 1 revision

If you want to use Chamber with Github Actions, and run tests which relies on chamber secrets, how would you do this? Here is an example which demonstrates the problem:

class UsersControllerTest < ActionDispatch::IntegrationTest
  test "some test" do
    get user_url(@user)
  end
end

class UsersController < ApplicationController
  def show
    puts Chamber.dig!(:smtp_email, :mailhost)
  end
end

How can Github actions access this variable without Chamber's secrets key being known to Github?

The trick is to let Github know about your secret key. You can add it to your repository. In order to add it, you would go to your repository's setting page and add it like so:

Adding CHAMBER_KEY to Github Repository

Then, in your Github action, simply ensure that you set up the CHAMBER_KEY environment variable.:

# .github/workflows/
name: ci
on: [push, pull_request]

jobs:
  tests:
    name: Tests
    runs-on: ubuntu-latest
    env:
      CHAMBER_KEY: "${{ secrets.CHAMBER_KEY }}"

    # the rest of your actions

Special thanks to @benkoshy for adding this page.

Clone this wiki locally