Skip to content

Commit 19a3a61

Browse files
authored
docs: add guide for pinning github actions (#1215)
Signed-off-by: nagaraju504 <[email protected]> Signed-off-by: Nagaraju Shivapalli <[email protected]> Co-authored-by: nagaraju504 <[email protected]>
1 parent 64cfe32 commit 19a3a61

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
1313
delegated spending behavior and key concepts. [#1202](https://github.com/hiero-ledger/hiero-sdk-python/issues/1202)
1414
- Added a GitHub Actions workflow to validate broken Markdown links in pull requests.
1515
- Added method chaining examples to the developer training guide (`docs/sdk_developers/training/coding_token_transactions.md`) (#1194)
16+
- Added documentation explaining how to pin GitHub Actions to specific commit SHAs (`docs/sdk_developers/how-to-pin-github-actions.md`)(#1211)
1617
- examples/mypy.ini for stricter type checking in example scripts
1718
- Added a GitHub Actions workflow that reminds contributors to link pull requests to issues.
1819
- Added `__str__` and `__repr__` methods to `AccountInfo` class for improved logging and debugging experience (#1098)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# How to Pin GitHub Actions to a Specific Commit Hash
2+
3+
## Overview
4+
5+
When creating or updating GitHub workflows in the Hiero Python SDK, **all GitHub Actions must be pinned to a specific commit hash** rather than using floating tags.
6+
7+
This document explains **why pinning is required**, **how to find the correct commit hash**, and **best practices** for maintaining pinned GitHub Actions.
8+
9+
---
10+
11+
## Why Pin GitHub Actions?
12+
13+
GitHub Actions can be referenced in multiple ways:
14+
15+
```yaml
16+
uses: owner/action@v1 # ❌ floating tag
17+
uses: owner/action@v4 # ⚠️ major version tag
18+
uses: owner/action@<commit> # ✅ pinned commit SHA (v2.14.0)
19+
```
20+
21+
### Security and supply-chain risk
22+
23+
GitHub Actions referenced using tags such as `latest`, `v1`, or `v4` are **mutable** and can be updated to point to a different commit at any time. This means the code executed by a workflow can change without any modification to the workflow file itself.
24+
25+
If an action repository is compromised or a malicious change is introduced upstream, workflows that rely on floating tags may unknowingly execute untrusted code. This represents a significant **software supply-chain risk**.
26+
27+
By pinning a GitHub Action to a specific commit SHA, the exact code being executed is known and cannot change unexpectedly. This makes workflows more secure, auditable, and resistant to supply-chain attacks.
28+
29+
For this reason, many security tools (for example, StepSecurity) require GitHub Actions to be pinned to commit SHAs.
30+
31+
### Reproducibility and stability
32+
33+
Pinning GitHub Actions to a specific commit SHA ensures workflows are fully reproducible. The same workflow will always execute the same version of an action, regardless of new releases or tag updates made upstream.
34+
35+
This prevents unexpected behavior changes caused by automatic updates to floating tags and makes CI runs more predictable.
36+
37+
Reproducible workflows are easier to debug, audit, and maintain, since any failures can be traced back to a known and immutable version of the action.
38+
39+
## Step-by-step: How to find the correct commit SHA
40+
41+
### Step 1: Open the action’s GitHub repository
42+
43+
Start with the official GitHub repository for the action. Prefer repositories linked from the GitHub Marketplace and ensure the project is actively maintained.
44+
45+
Examples:
46+
- actions/checkout
47+
- step-security/harden-runner
48+
49+
### Step 2: Go to the Releases page
50+
51+
In the repository, navigate to **Releases** and open the **Latest** release.
52+
53+
### Step 3: Open the release tag
54+
55+
Click the release version (for example `v2.14.0`) to open the release details page.
56+
57+
### Step 4: Copy the commit SHA
58+
59+
From the release page, open the commit associated with the release and copy the full 40-character commit SHA.
60+
61+
Example SHA: 20cf305ff2072d973412fa9b1e3a4f227bda3c76
62+
63+
### Step 5: Update the workflow
64+
65+
Replace any floating or version-based reference:
66+
67+
```yaml
68+
uses: step-security/harden-runner@v2
69+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
70+
```
71+
72+
## Best practices
73+
74+
- Always pin GitHub Actions to a full commit SHA
75+
- Avoid floating tags such as `latest`, `v1`, or `v4`
76+
- Keep a version comment (for example `# v2.14.0`)
77+
- Review release notes before updating pinned SHAs
78+
- Periodically update pinned actions to include security fixes
79+
- Avoid deprecated or archived action repositories

0 commit comments

Comments
 (0)