https://github.com/step-security/gh-docker-logs
GitHub Action to collect logs from all docker containers.
https://github.com/step-security/gh-docker-logs
step-security-maintained-actions
Last synced: 2 months ago
JSON representation
GitHub Action to collect logs from all docker containers.
- Host: GitHub
- URL: https://github.com/step-security/gh-docker-logs
- Owner: step-security
- License: mit
- Created: 2024-07-04T12:05:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-10T07:43:06.000Z (over 1 year ago)
- Last Synced: 2025-02-10T08:24:04.371Z (over 1 year ago)
- Topics: step-security-maintained-actions
- Language: TypeScript
- Homepage:
- Size: 2.11 MB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Collect Docker Logs
[](https://github.com/semantic-release/semantic-release)
This is a GitHub Action which will collect logs from all running docker
containers. Logs can either be dumped to stdout, or can be written to a
folder (where you can tar them up and
[upload them as an artifact](https://github.com/actions/upload-artifact)).
## Inputs
- `dest` - Destination folder to write to. If not provided, logs will be
written to stdout. If provided, the folder will be created if it doesn't
exist, and files will be written based on container names (e.g. 'redis.log').
- `images` - A comma delimited list of image names. If provided, only output
from containers with these images will be shown. Containers will match if
the image matches exactly (e.g. "mongo:3.4.22") or if the image name matches
without a tag (e.g. "mongo" will match "mongo:3.4.22").
- `tail` - Max number of lines to show from each container. Defaults to "all".
- `shell` - Shell to execute commands. Defaults to "/bin/sh".
## Usage
## Dump all logs on a failure
```yaml
- name: Dump docker logs on failure
if: failure()
uses: step-security/gh-docker-logs@v2
```
## Dump redis and mongodb logs
```yaml
- name: Dump redis logs
uses: step-security/gh-docker-logs@v2
with:
images: 'redis,mongo'
# Only show last 100 lines of each
tail: '100'
```
## Upload tarball as artifact
```yaml
- name: Collect docker logs on failure
if: failure()
uses: step-security/gh-docker-logs@v2
with:
dest: './logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Upload logs to GitHub
if: failure()
uses: actions/upload-artifact@master
with:
name: logs.tgz
path: ./logs.tgz
```
## Dump all logs on a failure using different shell
```yaml
- name: Dump docker logs on failure using different shell
if: failure()
uses: step-security/gh-docker-logs@v2
with:
shell: '/bin/sh'
```