Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ steps:

- `event_trigger_service`: (Optional) The hostname of the service that should be observed.

- `deploy_timeout`: (Optional) The function deployment timeout in seconds. Defaults to 300.

## Allow unauthenticated requests

A Cloud Functions product recommendation is that CI/CD systems not set or change
Expand Down
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ inputs:
The hostname of the service that should be observed.
required: false

deploy_timeout:
description: |-
The function deployment timeout in seconds.
required: false

outputs:
url:
description: The URL of your Cloud Function. Only available with HTTP Trigger.
Expand Down
7 changes: 7 additions & 0 deletions src/cloudFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type KVPair = {
* @param eventTriggerType Specifies which action should trigger the function.
* @param eventTriggerResource Specifies which resource from eventTrigger is observed.
* @param eventTriggerService The hostname of the service that should be observed.
* @param deployTimeout The function deployment timeout in seconds.
* @param labels List of key-value pairs to set as function labels.
*/

Expand All @@ -60,6 +61,7 @@ export type CloudFunctionOptions = {
eventTriggerType?: string;
eventTriggerResource?: string;
eventTriggerService?: string;
deployTimeout?: string;
labels?: string;
};

Expand All @@ -74,6 +76,8 @@ export class CloudFunction {
readonly name: string;
readonly sourceDir: string;
readonly functionPath: string;
readonly deployTimeout: number;

constructor(opts: CloudFunctionOptions) {
this.functionPath = `${opts.parent}/functions/${opts.name}`;

Expand Down Expand Up @@ -138,6 +142,9 @@ export class CloudFunction {
this.request = request;
this.name = opts.name;
this.sourceDir = opts.sourceDir ? opts.sourceDir : './';
this.deployTimeout = opts.deployTimeout
? parseInt(opts.deployTimeout)
: 300;
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/cloudFunctionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import * as path from 'path';
import * as os from 'os';
import { GaxiosResponse } from 'gaxios';
import { CloudFunction } from './cloudFunction';
import { uploadSource, zipDir, deleteZipFile } from './util';
import { google, cloudfunctions_v1 } from 'googleapis';
import { deleteZipFile, uploadSource, zipDir } from './util';
import { cloudfunctions_v1, google } from 'googleapis';
import {
Compute,
GoogleAuth,
JWT,
Compute,
UserRefreshClient,
} from 'google-auth-library';

Expand Down Expand Up @@ -100,6 +100,7 @@ export class CloudFunctionClient {

this.parent = `projects/${projectId}/locations/${region}`;
}

/**
* Retrieves the auth client for authenticating requests.
*
Expand Down Expand Up @@ -260,7 +261,7 @@ export class CloudFunctionClient {
updateFunctionResponse.data,
'Updating function deployment',
2,
150,
cf.deployTimeout / 2,
);
core.info('Function deployment updated');
return awaitUpdate;
Expand All @@ -287,6 +288,7 @@ export class CloudFunctionClient {
return awaitCreate;
}
}

/**
* Delete a Cloud Function.
*
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async function run(): Promise<void> {
const eventTriggerType = core.getInput('event_trigger_type');
const eventTriggerResource = core.getInput('event_trigger_resource');
const eventTriggerService = core.getInput('event_trigger_service');
const deployTimeout = core.getInput('deploy_timeout');
const labels = core.getInput('labels');

// Create Cloud Functions client
Expand All @@ -58,6 +59,7 @@ async function run(): Promise<void> {
eventTriggerType,
eventTriggerResource,
eventTriggerService,
deployTimeout,
vpcConnector,
serviceAccountEmail,
labels,
Expand Down