A GitHub Action that checks for immutable releases configuration and creates a release with all artifacts from the current pipeline run. Designed for compliance, audit trails, and artifact retention in regulated environments.
- β Immutable Releases Assessment: Evaluates repository capability for GitHub's immutable releases feature
- π¦ Complete Artifact Collection: Discovers and collects all artifacts from the current workflow run
- π Automated Release Creation: Creates comprehensive GitHub releases with rich metadata
- π Audit Trail: Provides detailed pipeline information and validation summaries
- π Compliance Ready: Designed for QMS/regulatory compliance with full traceability
- π‘οΈ Error Resilience: Robust error handling with graceful degradation
- β‘ Performance Optimized: Efficient artifact processing and minimal API calls
For QMS compliance and regulatory environments:
retain_pipeline_run:
runs-on: ubuntu-latest
needs: post_release_tag_commit
if: always() && !failure() && !cancelled() && contains(github.ref_name, 'release')
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true # Required for git tag detection
- name: Retain Pipeline Artifacts
uses: NovoNordisk-OpenSource/retain_pipeline_run@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}| Input | Description | Required | Default |
|---|---|---|---|
github_token |
GitHub token with repository and release permissions | β | - |
| Output | Description | Example |
|---|---|---|
release_id |
ID of the created release | 123456789 |
release_url |
URL of the created release | https://github.com/owner/repo/releases/tag/v1.0.0 |
release_tag |
Tag of the created release | v1.0.0 |
immutable_releases_enabled |
Whether immutable releases are supported | true |
artifacts_count |
Number of artifacts attached | 5 |
The action evaluates your repository's potential for GitHub's immutable releases feature:
What Immutable Releases Provide:
- Git tags cannot be moved or deleted after release publication
- Release assets cannot be modified or deleted
- Automatic generation of release attestations for cryptographic verification
- Protection against repository resurrection attacks
Assessment Factors:
- Organization Context: Checks if repository belongs to an organization
- Security Features: Evaluates GitHub Advanced Security indicators
- Repository Configuration: Considers visibility and access patterns
Automatically finds and catalogs all artifacts:
# Discovers artifacts from current workflow run
GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts
# Collects metadata for each artifact:
- Name and ID
- Size and creation timestamp
- Download URL and permissionsCreates comprehensive releases with:
- Pipeline Metadata: Run ID, commit SHA, branch, workflow name
- Execution Context: Trigger event, actor, timestamp
- Artifact Inventory: Complete list with sizes and descriptions
- Compliance Information: Immutable release status
- Rich Formatting: Markdown formatting with links and emojis
Downloads and attaches artifacts:
# For each artifact:
1. Download as ZIP archive
2. Attach to GitHub release
3. Verify successful upload
4. Report attachment statusYour workflow needs the following permissions:
permissions:
contents: write # Create releases and attach artifacts
actions: read # Access workflow run artifactsThe github_token must have:
reposcope (for private repositories)public_reposcope (for public repositories)- Release creation permissions
- Artifact read access
# Clone the repository
git clone https://github.com/NovoNordisk-OpenSource/retain_pipeline_run.git
cd retain_pipeline_run
# Run unit tests
./test/unit/run_tests.sh
# Run integration tests
./test/integration/run_tests.sh
# Run local development tests
./test/local_test.shThe repository includes comprehensive test workflows:
# Run basic functionality tests
gh workflow run ci.yml
# Run end-to-end tests with real artifacts
gh workflow run e2e-test.yml
# Run performance tests with large artifacts
gh workflow run performance-test.yml# Prerequisites
- GitHub CLI (gh)
- jq for JSON processing
- Standard Unix tools (curl, tar, etc.)
# Environment variables for testing
export GITHUB_REPOSITORY="owner/repo"
export GITHUB_RUN_ID="123456789"
export GITHUB_TOKEN="your_token"
export GITHUB_SHA="commit_sha"- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Write tests for your changes
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
The action creates releases with comprehensive information:
## π QMS Implementation Release
This release contains all artifacts from the QMS pipeline validation process.
### π Pipeline Information
- **Run ID:** [123456789](https://github.com/owner/repo/actions/runs/123456789)
- **Commit:** [`abc123def`](https://github.com/owner/repo/commit/abc123def456)
- **Branch:** `release/v1.0.0`
- **Workflow:** `QMS Validation Pipeline`
- **Triggered by:** `push`
- **Actor:** @developer
- **Created:** 2024-11-27 14:30:22 UTC
### π¦ Artifacts (5)
This release contains **5** artifacts with a total size of **15.2 MiB**:
- **validation-results** (8.1 MiB)
- **test-reports** (4.2 MiB)
- **security-scans** (1.8 MiB)
- **performance-metrics** (892 KiB)
- **compliance-docs** (341 KiB)
> πΎ **Retention Period:** Indefinite (GitHub releases)
### π Immutable Release
β‘ **This release benefits from GitHub's immutable releases capability.**
Detected features: `secret_scanning_enabled,organization_repository`
---
*π€ This release was created automatically by the [retain_pipeline_run](https://github.com/NovoNordisk-OpenSource/retain_pipeline_run) action*- Token Security: Use repository secrets for GitHub tokens
- Artifact Access: Respects repository and artifact permissions
- Immutable Storage: Leverages GitHub's release immutability when available
- Audit Logging: All actions are logged in GitHub's audit log
- π GitHub Immutable Releases Documentation
- π§ GitHub Actions Artifacts Documentation
- π GitHub Releases API
- π₯ QMS Implementation Guide
This project is licensed under the MIT License - see the LICENSE file for details.
- π Bug Reports: GitHub Issues
- π‘ Feature Requests: GitHub Discussions