To use Google Cloud Storage (GCS) as the backend for the cache server, you can initialize the GcsAdapter using the fromEnv static method. This method requires specific environment variables to be set.
Required environment variables:
STORAGE_DRIVER: Must be set to gcs.STORAGE_GCS_BUCKET: The name of your GCS bucket.STORAGE_GCS_SERVICE_ACCOUNT_KEY: Path to your GCS service account key file.STORAGE_GCS_ENDPOINT: The API endpoint for GCS (if using a custom endpoint or emulator).
Note: The adapter automatically uses the prefix gh-actions-cache for all objects stored in the bucket to prevent namespace collisions.
// The adapter is initialized via environment variables
// STORAGE_DRIVER=gcs
// STORAGE_GCS_BUCKET=my-cache-bucket
// STORAGE_GCS_SERVICE_ACCOUNT_KEY=/path/to/key.json
// STORAGE_GCS_ENDPOINT=https://storage.googleapis.com
const adapter = await GcsAdapter.fromEnv(env);