This GitHub Action provides the functionality to compress or decompress files
using various compression formats including zip, tar, tgz, and tbz2. It
is designed to be easy to use within GitHub workflows for handling file
compression and decompression tasks efficiently.
Key Features:
- Glob Pattern Support - Match multiple files with patterns like
**/*.doc - Symbolic Link Support - Automatically follows symlinks (Bazel, Buck, and build tool integration)
- Path Stripping - Remove path prefixes while preserving directory structure
- Multiple Formats - Support for zip, tar, tgz, and tbz2
- Flexible Options - Custom destinations, exclude patterns, and root control
| Input | Description | Required | Default |
|---|---|---|---|
command |
The operation to perform. It can be either "compress" or "decompress" | Yes | - |
source |
The source directory, file, or glob pattern to compress or decompress. Supports glob patterns like **/*.doc to match multiple files. |
Yes | - |
dest |
The destination directory for the output. If not provided, it defaults to the current working directory. | No | - |
destfilename |
The destination filename for the output (extension is appended depending on the format). If not provided, it defaults to the current working directory's name. | No | - |
exclude |
Filename (or pattern) to exclude from compression process. | No | - |
format |
The compression format to use. Supported formats are zip, tar, tgz, and tbz2. |
Yes | - |
includeRoot |
Whether to include the root folder itself in the compressed file. | No | yes |
preserveGlobStructure |
When using glob patterns, preserve the directory structure in the archive. If false, all matched files are flattened to the root level. | No | false |
stripPrefix |
Remove this prefix from file paths when preserving directory structure. Works only with glob patterns and preserveGlobStructure: true. Example: 'src/' changes src/app/main.py to app/main.py in the archive. |
No | "" |
fail_on_error |
Whether to fail the action if compression/decompression fails. | No | true |
verbose |
Enable verbose logging for debugging purposes. | No | false |
| Output | Description |
|---|---|
file_path |
The path to the compressed or decompressed file. |
You can use this action in your GitHub workflow by specifying the action with its required inputs.
- Glob Pattern Guide - Match multiple files with patterns like
**/*.doc - Advanced Usage Guide - Custom paths, exclude patterns, matrix strategies, and more
- Troubleshooting Guide - Solutions for common issues and debugging tips
- Testing Guide - Test setup, structure, and running tests locally
This example demonstrates how to use custom destination and filename options:
name: Compress Files with Custom Path
on: [push]
jobs:
compress-job:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Compress Directory
uses: somaz94/compress-decompress@v1
with:
command: compress
source: ./data-folder
format: zip
dest: './custom_output'
destfilename: 'my_archive'
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: compressed-data
path: ./custom_output/my_archive.zipExclude specific files or directories from compression:
- name: Compress Repository Excluding Git Files
uses: somaz94/compress-decompress@v1
with:
command: compress
source: .
format: zip
dest: './artifacts'
destfilename: 'repo-backup'
exclude: '.git .github node_modules *.log'- Version control:
.git .svn - Dependencies:
node_modules vendor - Temporary files:
*.log *.tmp
π View Advanced Usage Guide β
This action supports glob patterns for matching multiple files across your repository. This is useful when you need to archive specific file types without compressing entire directories.
- name: Compress All Documentation Files
uses: somaz94/compress-decompress@v1
with:
command: compress
source: '**/*.md'
format: zip
dest: './artifacts'
destfilename: 'all-docs'**/*.ext- All files with extension in all subdirectoriesdir/**/*.ext- All files with extension in specific directory**/*.{ext1,ext2}- Multiple file types
- Files are collected into a flattened archive structure by default
- Use
preserveGlobStructure: trueto maintain directory structure - Use
stripPrefixto remove path prefixes (e.g.,'src/'removes src/ from all paths) - No matches will fail by default (use
fail_on_error: falseto override) - Enable
verbose: trueto see matched files
- name: Archive Logs with Directory Structure
uses: somaz94/compress-decompress@v1
with:
command: compress
source: '**/*.log'
format: zip
preserveGlobStructure: true # Preserves dir/subdir1/file.log structure- name: Archive Source Files Without Project Root
uses: somaz94/compress-decompress@v1
with:
command: compress
source: 'project/src/**/*.ts'
format: zip
preserveGlobStructure: true
stripPrefix: 'project/' # Changes project/src/app/main.ts to src/app/main.tsπ View Complete Glob Pattern Guide β
- name: Compress Directory
uses: somaz94/compress-decompress@v1
with:
command: compress
source: ./data-folder
format: zip- name: Decompress Archive
uses: somaz94/compress-decompress@v1
with:
command: decompress
source: ./data-folder.zip
format: zip
dest: './unpacked'Compression fails with "Source not found"?
- Verify source path exists:
ls -la ./data-folder - Use absolute paths:
${{ github.workspace }}/data-folder - Check workspace state:
ls -la ${{ github.workspace }} - See Troubleshooting Guide
Glob pattern not matching files?
- Verify files exist:
find . -name "*.doc" - Enable verbose mode:
verbose: true - Check pattern syntax: Use single quotes
'**/*.doc' - See Glob Pattern Guide
Archive size is too large?
- Use exclude patterns:
exclude: 'node_modules .git *.log' - Use better compression:
format: tbz2instead ofzip - Split into multiple archives
- See Troubleshooting Guide
Exclude patterns not working?
Correct syntax (space-separated):
exclude: 'node_modules .git *.log'Incorrect (comma-separated):
exclude: 'node_modules,.git,*.log' # Wrong!β See full troubleshooting guide
Contributions welcome! Please:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and test locally
- Commit:
git commit -am "feat: Add new feature" - Push and create a Pull Request
python3 -m venv .venv
source .venv/bin/activate
pip install pytest
python -m pytest tests/ -vβ See full testing guide | β See development and testing guide
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full Documentation
Thanks to all contributors:
Made with efficiency for GitHub Actions workflows