-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 12.7.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
# Setup Gcloud | ||
# Setup and Activate GCloud | Github Action | ||
|
||
Very simple javascript action for setting up google cloud CLI `gcloud` command | ||
Very simple javascript github action for setting up google cloud CLI `gcloud` command with an service-account for authentication and permissions. | ||
|
||
## Options | ||
|
||
#### Channel | ||
#### Service Account | ||
|
||
What snap channel to use, Default: `stable` | ||
The service account to activate in order to call authenticated gcloud requests. The value given to it must be a base64 encoded github secret of a google service account json file. | ||
|
||
``` | ||
service_account: ${{ secrets.GCLOUD_AUTH }} | ||
``` | ||
|
||
If service_account is not provided no service account will be activated for authenticated requets using the cli. However you are still able to upgrade gcloud and use public non authenticated requests. | ||
|
||
#### Upgrade | ||
|
||
Either to upgrade to latest version of gcloud or not. | ||
|
||
Default Value: `no` | ||
|
||
Possible Values: | ||
|
||
``` | ||
'no' | 'yes' | 'snap' | ||
``` | ||
|
||
_Snap_: Will install the latest gcloud version using a snap package instead of apt-get which is slightly slower than snap. | ||
|
||
**Note** Upgrading at all is considerably slower, Only upgrade if the runners gcloud is broken on the current version it uses. | ||
|
||
## Example | ||
|
||
Activate with service account and upgrade using snap package. | ||
|
||
``` | ||
- uses: mango-chutney/mango-actions-setup-gcloud@releases/v1 | ||
with: | ||
service_account: ${{ secrets.GCLOUD_AUTH }} | ||
upgrade: 'snap' | ||
``` | ||
|
||
Most common usage will not include upgrading because it is considerably faster to run. | ||
|
||
``` | ||
- uses: mango-chutney/mango-actions-setup-gcloud@v1 | ||
- uses: mango-chutney/mango-actions-setup-gcloud@releases/v1 | ||
with: | ||
channel: 'stable' | ||
service_account: ${{ secrets.GCLOUD_AUTH }} | ||
``` | ||
|
||
### TODO | ||
|
||
#### Upgrade / Downgrade Using gcloud components |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const exec = __importStar(require("@actions/exec")); | ||
const upgradeScript = (upgrade) => __awaiter(this, void 0, void 0, function* () { | ||
if (upgrade === 'no') { | ||
return console.log('GCloud Upgrade not requested'); | ||
} | ||
if (upgrade === 'snap') { | ||
// Install Gcloud Snap | ||
yield exec.exec('sudo snap install google-cloud-sdk --channel=stable --classic'); | ||
// Ensure root is owned (So that snap can run, Possible security issue) | ||
yield exec.exec('sudo chown root:root /'); | ||
return console.log('GCloud Upgraded using Snap'); | ||
} | ||
if (upgrade === 'yes') { | ||
// Add the Cloud SDK distribution URI as a package source | ||
yield exec.exec('echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" >> /etc/apt/sources.list.d/google-cloud-sdk.list'); | ||
// Import the Google Cloud Platform public key (Save file then import it (Piping is not supported with exec)) | ||
yield exec.exec('curl -o gcp-apt-key.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg'); | ||
yield exec.exec('sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add gcp-apt-key.gpg'); | ||
// Update the package list and install the Cloud SDK | ||
yield exec.exec('sudo apt-get update'); | ||
return yield exec.exec('sudo apt-get install --only-upgrade google-cloud-sdk'); | ||
} | ||
return null; | ||
}); | ||
exports.default = upgradeScript; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.