Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: updates for v1 #300

Merged
merged 2 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 0 additions & 69 deletions .github/workflows/integration.yml
Expand Up @@ -81,75 +81,6 @@ jobs:
with:
path: './test'
destination: '${{ secrets.UPLOAD_CLOUD_STORAGE_TEST_BUCKET }}/testprefix'
credentials: '${{ secrets.UPLOAD_CLOUD_STORAGE_GCP_SA_KEY_JSON }}'

- name: 'Get output'
run: 'echo "${{ steps.upload.outputs.uploaded }}"'

# Deprecated
auth_setup_gcloud:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
name: 'auth_setup_gcloud'
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3'

- uses: 'actions/setup-node@v3'
with:
node-version: '16.x'

- name: 'npm build'
run: 'npm ci && npm run build'

- uses: 'google-github-actions/setup-gcloud@main'
with:
service_account_email: ${{ secrets.UPLOAD_CLOUD_STORAGE_GCP_SA_EMAIL }}
service_account_key: ${{ secrets.UPLOAD_CLOUD_STORAGE_GCP_SA_KEY_B64 }}
export_default_credentials: true

- name: 'Create files'
run: |-
mkdir -p test
touch test/test2.txt
- id: 'upload'
name: 'Upload files'
uses: './'
with:
path: './test/test2.txt'
destination: '${{ secrets.UPLOAD_CLOUD_STORAGE_TEST_BUCKET }}/testprefix'

- name: 'Get output'
run: 'echo "${{ steps.upload.outputs.uploaded }}"'

# Deprecated
auth_builtin_credentials:
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
name: 'auth_builtin_credentials'
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v3'

- uses: 'actions/setup-node@v3'
with:
node-version: '16.x'

- name: 'npm build'
run: 'npm ci && npm run build'

- name: 'Create files'
run: |-
mkdir -p test
touch test/test1.txt
touch test/test2.txt
- id: 'upload'
name: 'Upload files'
uses: './'
with:
path: './test'
destination: '${{ secrets.UPLOAD_CLOUD_STORAGE_TEST_BUCKET }}/testprefix'
credentials: '${{ secrets.UPLOAD_CLOUD_STORAGE_GCP_SA_KEY_JSON }}'

- name: 'Get output'
run: 'echo "${{ steps.upload.outputs.uploaded }}"'
12 changes: 1 addition & 11 deletions README.md
Expand Up @@ -302,13 +302,6 @@ If `parent` is set to `false`, it wil be uploaded to `gs://bucket-name/folder2/f
project_id: 'my-project'
```

- `credentials`: (**Deprecated**) This input is deprecated. See [auth
section](#via-google-github-actionsauth) for more details. [Google Service
Account JSON][sa] credentials as JSON or base64 encoded string, typically
sourced from a [GitHub Secret][gh-secret]. If unspecified, other
authentication methods are attempted. See [Authorization](#Authorization)
below.

## Outputs

List of successfully uploaded file(s).
Expand Down Expand Up @@ -396,7 +389,4 @@ Credentials.

[gcs]: https://cloud.google.com/storage
[wif]: https://cloud.google.com/iam/docs/workload-identity-federation
[sa]: https://cloud.google.com/iam/docs/creating-managing-service-accounts
[gh-runners]: https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
[gh-secret]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
[setup-gcloud]: ../setup-gcloud
[sa]: https://cloud.google.com/iam/docs/creating-managing-service-accounts
bharathkkb marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 0 additions & 6 deletions action.yml
Expand Up @@ -3,12 +3,6 @@ description: Upload files or folders to GCS buckets
author: Google LLC

inputs:
credentials:
description: |-
Optional service account key to use for authentication to GCS. This should be the JSON
formatted private key which can be exported from the Cloud Console. The
value can be raw or base64-encoded.
required: false
project_id:
description: |-
Project ID to use for making requests. By default, this is extracted from
Expand Down
8 changes: 1 addition & 7 deletions src/client.ts
Expand Up @@ -18,7 +18,6 @@ import * as path from 'path';

import { Storage, StorageOptions, PredefinedAcl } from '@google-cloud/storage';
import {
parseCredential,
randomFilepath,
inParallel,
toPlatformPath,
Expand All @@ -38,10 +37,9 @@ const userAgent = `google-github-actions:upload-cloud-storage/${appVersion}`;
/**
* Available options to create the client.
*
* @param credentials GCP JSON credentials (default uses ADC).
* @param projectID GCP Project ID.
*/
export type ClientOptions = {
credentials?: string;
projectID?: string;
};

Expand Down Expand Up @@ -165,10 +163,6 @@ export class Client {
userAgent: userAgent,
};

if (opts?.credentials) {
options.credentials = parseCredential(opts.credentials);
}

this.storage = new Storage(options);
}

Expand Down
11 changes: 0 additions & 11 deletions src/main.ts
Expand Up @@ -67,18 +67,8 @@ export async function run(): Promise<void> {
const headersInput = core.getInput('headers');
const processGcloudIgnore = core.getBooleanInput('process_gcloudignore');
const metadata = headersInput === '' ? {} : parseHeadersInput(headersInput);
const credentials = core.getInput('credentials');
const projectID = core.getInput('project_id');

// Add warning if using credentials.
if (credentials) {
core.warning(
'The "credentials" input is deprecated. ' +
'Please switch to using google-github-actions/auth which supports both Workload Identity Federation and JSON Key authentication. ' +
'For more details, see https://github.com/google-github-actions/upload-cloud-storage#authorization',
);
}

// Compute the absolute root and compute the glob.
const [absoluteRoot, computedGlob, rootIsDir] = await absoluteRootAndComputedGlob(root, glob);
core.debug(`Computed absoluteRoot from "${root}" to "${absoluteRoot}" (isDir: ${rootIsDir})`);
Expand Down Expand Up @@ -155,7 +145,6 @@ export async function run(): Promise<void> {
// Create the client and upload files.
core.startGroup('Upload files');
const client = new Client({
credentials: credentials,
projectID: projectID,
});
const uploadResponses = await client.upload({
Expand Down
7 changes: 0 additions & 7 deletions tests/client.test.ts
Expand Up @@ -29,13 +29,6 @@ describe('Client', () => {
});

describe('#new', () => {
it('initializes with JSON creds', function () {
const client = new Client({
credentials: `{"foo":"bar"}`,
});
expect(client.storage.authClient.jsonContent).eql({ foo: 'bar' });
});

it('initializes with ADC', function () {
const client = new Client();
expect(client.storage.authClient.jsonContent).eql(null);
Expand Down