How to pass Github secret into the script?

Hello, I’m trying to configure K6 to run in our GH CI/CD, I have a GH secret “TOKEN” that contains Bearer token for the request we are sending:

const params = {
    metadata: {
      'Authorization': 'Bearer <token>'
    }
};

How should I rename <token>or maybe what should I specify in .github/workflows/load-test.yml file so that it takes token from GH secrets?

Here is my .yml file:

k6_load_test:
  name: k6 Load Test
  runs-on: ubuntu-latest

  steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Run local k6 test
      uses: grafana/k6-action@v0.2.0
      with:
        filename: ../../perfomance test/k6-script-test.js
        token: ${{ secrets.K6_CLOUD_API_TOKEN }}

Hi @mod_noise

I’m in no way a specialist of our k6-action GH action, but, looking at its content, I assume you should be able to access this value from the environment?

Something along the lines of the following might work

const token = __ENV.K6_CLOUD_TOKEN || ''

// and then 
const params = {
    metadata: {
      'Authorization': `Bearer ${token}`
    }
};

Let me know if that helps :bowing_man: