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

Add docs and example for Google Cloud Storage destination #22

Merged
merged 16 commits into from
May 26, 2024
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
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![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)

`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.
`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.

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.

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

The following inputs are required regardless of the chosen destination:

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

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

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

### [Google Cloud Storage](https://cloud.google.com/storage/)

[Example](examples/google-cloud-storage/)

The Cloud Storage exporter uses the Object Writer API to save the workflow logs file.

The following inputs are required if `destination` is `cloudstorage`:

| Name | Description |
| --------------------------- | -------------------------------------------------------- |
| `cloud-storage-bucket-name` | The name of the Google Cloud Storage bucket to upload to |
| `cloud-storage-object-name` | Object name to save the workflow logs as |

## Development

### Testing
Expand Down
3 changes: 3 additions & 0 deletions examples/google-cloud-storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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.

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.
29 changes: 29 additions & 0 deletions examples/google-cloud-storage/export-logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Export To Google Cloud Storage
on:
workflow_run:
workflows: [Hello World]
types: [completed]
jobs:
export-hello-world-logs:
permissions:
contents: "read"
id-token: "write"
actions: "read"

runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v4"

- uses: "google-github-actions/auth@v2"
with:
project_id: "foo-project"
service_account: "[email protected]"
workload_identity_provider: "projects/1234567/locations/global/workloadIdentityPools/foo/providers/bar"

- uses: timorthi/export-workflow-logs@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
destination: cloudstorage
cloud-storage-bucket-name: foo-workflow-logs
cloud-storage-object-name: ${{ github.event.workflow_run.name }}/${{ github.event.workflow_run.created_at }}-runId${{ github.event.workflow_run.id }}.zip
8 changes: 8 additions & 0 deletions examples/google-cloud-storage/hello-world.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Hello World
on: workflow_dispatch
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- name: Print Hello World
run: echo "Hello World!"
Loading