felixmosh / turborepo-gh-artifacts

A TurboRepo local cache server which uploads artifact cache to GH artifacts.
MIT License
122 stars 7 forks source link

refactor(turboServer): use environment variables for configuration #18

Closed johnhooks closed 1 year ago

johnhooks commented 1 year ago

The suggest way to initiate TurboRepo in CI seems to be to use environment variables:

Modified except from Remote Caching (I added TURBO_REMOTE_ONLY)

jobs:
  build:
    name: Build and Test
    runs-on: ubuntu-latest
    # To use Turborepo Remote Caching, set the following environment variables for the job.
    env:
      TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
      TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
      TURBO_REMOTE_ONLY: true

And it looks like they didn't document it but from what it looks like, TurboRepo might just use a TURBO_API environment variable... here is what I'm basing the idea on reference, I'll be testing this soon.

If I'm already using an environment variable for the turbo cli command in my workflow steps, is there any issue with modifying this as so... or even remove the server-token input?

// src/turboServer.ts line 16
const serverToken = process.env.TURBO_TOKEN || getInput(Inputs.SERVER_TOKEN, {
  required: true,
  trimWhitespace: true,
});

Then there isn't any need to pass turbo special arguments in CI. It should just use the remote caching server or fail.

If this works would you be interested in a PR?

felixmosh commented 1 year ago

ServerToken is the key to make sure that you are the one that "talks" with the local server, nothing more than that.