@google-github-actions/setup-cloud-sdk
Version:
Utilities to download, install, and interact with the Cloud SDK for GitHub Actions
71 lines (47 loc) • 1.99 kB
Markdown
Setup Cloud SDK for GitHub Actions API client for Node.js
A comprehensive list of changes in each version may be found in
[](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/CHANGELOG.md).
* [Client API Reference](./docs/modules.md)
**Table of contents:**
* [Installing the client library](
* [Using the client library](
* [Versioning](
* [Contributing](
* [License](
**This is not an officially supported Google product, and it is not covered by a
Google Cloud support contract. To report bugs or request features in a Google
Cloud product, please contact [Google Cloud
support](https://cloud.google.com/support).**
```bash
npm install @google-github-actions/setup-cloud-sdk
```
```TS
import * as core from '@actions/core';
import * as toolCache from '@actions/tool-cache';
import * as setupGcloud from '@google-github-actions/setup-cloud-sdk';
// Install gcloud if not already installed.
const gcloudVersion = await setupGcloud.getLatestGcloudSDKVersion();
if (!setupGcloud.isInstalled(gcloudVersion)) {
await setupGcloud.installGcloudSDK(gcloudVersion);
} else {
const toolPath = toolCache.find('gcloud', gcloudVersion);
core.addPath(path.join(toolPath, 'bin'));
}
// Authenticate gcloud SDK.
if (credentials) await setupGcloud.authenticateGcloudSDK(credentials);
const authenticated = await setupGcloud.isAuthenticated();
if (!authenticated) {
throw new Error('Error authenticating the Cloud SDK.');
}
const toolCommand = setupGcloud.getToolCommand();
```
This library follows [Semantic Versioning](http://semver.org/).
Contributions welcome! See the [Contributing Guide](./CONTRIBUTING.md).
Apache Version 2.0
See [LICENSE](./LICENSE)