Skip to content

Commit a62a990

Browse files
authored
Add docs and example for Google Cloud Storage destination (#22)
* feat: add google cloud sdk * feat: stub saveToCloudStorage * build: tidy * feat: declare cloud storage input keys * feat: add gcs input validation * feat: accept pointer * feat: add cloudStorageClient * feat: add google cloud storage destination * docs: add google cloud storage docs * build: build image for testing * docs: use correct keys * Revert "build: build image for testing" This reverts commit d3ed8d9. * docs: add gcs usage example * docs: add note to gcs example * docs: move example link next to header
1 parent 1fdc0e0 commit a62a990

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

README.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Maintainability](https://api.codeclimate.com/v1/badges/adf5dcf95b53da6c741f/maintainability)](https://codeclimate.com/github/timorthi/export-workflow-logs/maintainability) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44

5-
`export-workflow-logs` is a GitHub Action to automatically export the logs of a GitHub Actions Workflow run to popular cloud storage solutions like Amazon S3 and Azure Blob Storage.
5+
`export-workflow-logs` is a GitHub Action to automatically export the logs of a GitHub Actions Workflow run to popular cloud storage solutions like Amazon S3, Azure Blob Storage, and Google Cloud Storage.
66

77
The logs for workflow run are only [available for a limited time](https://docs.github.com/en/organizations/managing-organization-settings/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization) before they are automatically deleted. This Action moves workflow run logs to longer term storage to make them easily accessible in the future for auditing purposes.
88

@@ -77,11 +77,11 @@ This Action only supports one environment variable: set `DEBUG` to `true` to ena
7777

7878
The following inputs are required regardless of the chosen destination:
7979

80-
| Name | Description |
81-
| ------------- | ------------------------------------------------------------------------------------------------------------------ |
82-
| `repo-token` | Token to use to fetch workflow logs. Typically the `GITHUB_TOKEN` secret. |
83-
| `run-id` | The workflow run ID for which to export logs. Typically obtained via the `github` context per the above example. |
84-
| `destination` | The service to export workflow logs to. Supported values: [`s3`](#amazon-s3), [`blobstorage`](#azure-blob-storage) |
80+
| Name | Description |
81+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
82+
| `repo-token` | Token to use to fetch workflow logs. Typically the `GITHUB_TOKEN` secret. |
83+
| `run-id` | The workflow run ID for which to export logs. Typically obtained via the `github` context per the above example. |
84+
| `destination` | The service to export workflow logs to. Supported values: [`s3`](#amazon-s3), [`blobstorage`](#azure-blob-storage), [`cloudstorage`](#google-cloud-storage) |
8585

8686
### [Amazon S3](https://aws.amazon.com/s3/)
8787

@@ -111,6 +111,19 @@ The following inputs are required if `destination` is `blobstorage`:
111111
| `container-name` | The name of the Blob Storage Container to upload to |
112112
| `blob-name` | Blob name to save the workflow logs as |
113113

114+
### [Google Cloud Storage](https://cloud.google.com/storage/)
115+
116+
[Example](examples/google-cloud-storage/)
117+
118+
The Cloud Storage exporter uses the Object Writer API to save the workflow logs file.
119+
120+
The following inputs are required if `destination` is `cloudstorage`:
121+
122+
| Name | Description |
123+
| --------------------------- | -------------------------------------------------------- |
124+
| `cloud-storage-bucket-name` | The name of the Google Cloud Storage bucket to upload to |
125+
| `cloud-storage-object-name` | Object name to save the workflow logs as |
126+
114127
## Development
115128

116129
### Testing
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The Google Cloud Storage exporter uses the [Google Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go#hdr-Authentication_and_Authorization) under the hood.
2+
3+
This exporter does not accept Action-level inputs for credentials or path to credentials files. Authenticating to GCP via [google-github-actions/auth](https://github.com/google-github-actions/auth) is recommended.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Export To Google Cloud Storage
2+
on:
3+
workflow_run:
4+
workflows: [Hello World]
5+
types: [completed]
6+
jobs:
7+
export-hello-world-logs:
8+
permissions:
9+
contents: "read"
10+
id-token: "write"
11+
actions: "read"
12+
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: "actions/checkout@v4"
16+
17+
- uses: "google-github-actions/auth@v2"
18+
with:
19+
project_id: "foo-project"
20+
service_account: "[email protected]"
21+
workload_identity_provider: "projects/1234567/locations/global/workloadIdentityPools/foo/providers/bar"
22+
23+
- uses: timorthi/export-workflow-logs@v1
24+
with:
25+
repo-token: ${{ secrets.GITHUB_TOKEN }}
26+
run-id: ${{ github.event.workflow_run.id }}
27+
destination: cloudstorage
28+
cloud-storage-bucket-name: foo-workflow-logs
29+
cloud-storage-object-name: ${{ github.event.workflow_run.name }}/${{ github.event.workflow_run.created_at }}-runId${{ github.event.workflow_run.id }}.zip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Hello World
2+
on: workflow_dispatch
3+
jobs:
4+
hello-world:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Print Hello World
8+
run: echo "Hello World!"

0 commit comments

Comments
 (0)