Skip to content
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
32 changes: 31 additions & 1 deletion .github/workflows/__test-action-helm-release-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,45 @@ jobs:
helm-repositories: |
valkey https://valkey.io/valkey-helm/

- name: Arrange artifact input for the unsigned checksum rejection
id: artifact-name
if: ${{ !matrix.sign }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
ARCHIVE: ${{ steps.prepare.outputs.archive }}
with:
script: |
core.setOutput('name', require('node:path').basename(process.env.ARCHIVE));

- name: Upload checksum rejection fixture
id: artifact
if: ${{ !matrix.sign }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-checksum-rejection-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ steps.prepare.outputs.archive }}
if-no-files-found: error
retention-days: 1

- name: Act - Reject a mismatched archive before publication
id: mismatch
continue-on-error: true
uses: $/actions/helm/release-chart
with:
archive: ${{ steps.prepare.outputs.archive }}
archive: ${{ matrix.sign && steps.prepare.outputs.archive || '' }}
artifact-id: ${{ steps.artifact.outputs.artifact-id }}
archive-name: ${{ steps.artifact-name.outputs.name }}
checksum: "0000000000000000000000000000000000000000000000000000000000000000"
sign: false

- name: Assert failed publication cleans downloaded files
if: ${{ !matrix.sign }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const leftovers = require('node:fs').readdirSync(process.env.RUNNER_TEMP).filter(name => name.startsWith('helm-artifact-'));
if (leftovers.length) throw new Error(`Release action left downloaded archives: ${leftovers.join(', ')}`);

- name: Arrange - Remove source after preparation
env:
CHART_PATH: tests/charts/${{ matrix.chart.name }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helm-chart-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

Validate and publish the same prepared Helm chart archive.

This workflow reuses Helm chart CI, then downloads only its immutable artifact ID
in a separate publication job. The original checksum is checked before registry
This workflow reuses Helm chart CI, then passes its immutable artifact ID
to the release action in a separate publication job. The original checksum is checked before registry
login; no source checkout, packaging or dependency rebuild occurs in publication.
Validation uses read permissions and separate read-only image credentials.
Only publication receives packages write and OIDC. A failed/skipped/cancelled
Expand Down
44 changes: 4 additions & 40 deletions .github/workflows/helm-chart-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Validate and publish the same prepared Helm chart archive.
#
# This workflow reuses Helm chart CI, then downloads only its immutable artifact ID
# in a separate publication job. The original checksum is checked before registry
# This workflow reuses Helm chart CI, then passes its immutable artifact ID
# to the release action in a separate publication job. The original checksum is checked before registry
# login; no source checkout, packaging or dependency rebuild occurs in publication.
# Validation uses read permissions and separate read-only image credentials.
# Only publication receives packages write and OIDC. A failed/skipped/cancelled
Expand Down Expand Up @@ -183,51 +183,15 @@ jobs:
image-digest: ${{ job.status == 'success' && steps.release.outputs.image-digest || '' }}
checksum: ${{ job.status == 'success' && needs.validate.outputs.checksum || '' }}
steps:
- name: Require validated artifact identity
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
ARTIFACT_ID: ${{ needs.validate.outputs.artifact-id }}
ARCHIVE_NAME: ${{ needs.validate.outputs.archive-name }}
CHECKSUM: ${{ needs.validate.outputs.checksum }}
with:
script: |
const path = require('node:path');
const { ARTIFACT_ID, ARCHIVE_NAME, CHECKSUM } = process.env;
if (!/^[1-9][0-9]*$/.test(ARTIFACT_ID) || !/^[a-f0-9]{64}$/.test(CHECKSUM)
|| !ARCHIVE_NAME.endsWith('.tgz') || path.basename(ARCHIVE_NAME) !== ARCHIVE_NAME) {
throw new Error('Successful validation must supply one artifact ID, archive basename and checksum.');
}

- name: Download exact validated archive
id: download
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
artifact-ids: ${{ needs.validate.outputs.artifact-id }}
path: ${{ runner.temp }}/helm-publish-${{ needs.validate.outputs.artifact-id }}
digest-mismatch: error

- name: Publish and sign unchanged archive
id: release
uses: $/actions/helm/release-chart
with:
archive: ${{ steps.download.outputs.download-path }}/${{ needs.validate.outputs.archive-name }}
artifact-id: ${{ needs.validate.outputs.artifact-id }}
archive-name: ${{ needs.validate.outputs.archive-name }}
checksum: ${{ needs.validate.outputs.checksum }}
oci-registry: ${{ inputs.oci-registry }}
oci-registry-username: ${{ inputs.oci-registry-username || github.repository_owner }}
oci-registry-password: ${{ secrets.oci-registry-password || github.token }}
oci-repository: ${{ inputs.oci-repository || format('{0}/charts', github.repository) }}
sign: ${{ inputs.sign }}

- name: Clean downloaded archive
if: always()
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
ARTIFACT_ID: ${{ needs.validate.outputs.artifact-id }}
with:
script: |
if (/^[1-9][0-9]*$/.test(process.env.ARTIFACT_ID)) {
const path = require('node:path');
require('node:fs').rmSync(path.join(process.env.RUNNER_TEMP, `helm-publish-${process.env.ARTIFACT_ID}`), {
recursive: true, force: true,
});
}
52 changes: 32 additions & 20 deletions actions/helm/release-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@
## Overview

Publish one prepared Helm chart archive to an OCI registry.
Requires the archive and its expected SHA-256 checksum. Lint and test those same
bytes before calling this action. The caller retains its archive; temporary
publication files and registry credentials are removed on success or failure.
Supply either a local archive or an immutable artifact-id and archive-name from
this workflow run, plus the archive's expected SHA-256 checksum. Lint and test
those same bytes before calling this action. Artifact input downloads only that
ID, fails on artifact digest mismatch, and verifies the archive checksum before
registry access. The caller retains local archives; downloaded archives,
temporary publication files and credentials are removed on success or failure.
Gate publication on successful validation. Publication-only retries reuse its
artifact ID and checksum; missing or expired artifacts require validation again.
Signs the published chart digest with Cosign and GitHub Actions OIDC by default.
Set `sign` to `false` to opt out and still consume the immutable digest output.
Does not check out source, mutate values/metadata, rebuild dependencies or package.
Expand All @@ -37,20 +42,22 @@ Push retries reuse a verified snapshot of the supplied archive. Ensures Helm is

## Inputs

| **Input** | **Description** | **Required** | **Default** |
| --------------------------- | ------------------------------------------------------------------------------------- | ------------ | --------------------------------- |
| **`oci-registry`** | OCI registry where to push chart. | **true** | `ghcr.io` |
| **`oci-registry-username`** | OCI registry username. | **true** | `${{ github.repository_owner }}` |
| **`oci-registry-password`** | OCI registry password. | **true** | `${{ github.token }}` |
| **`oci-repository`** | OCI namespace without the registry or final chart name. | **false** | `${{ github.repository }}/charts` |
| | Defaults to {owner}/{repository}/charts. The archive supplies its chart name/version. | | |
| | Set this explicitly to preserve a different publication namespace. | | |
| **`archive`** | Path to the prepared .tgz archive. Relative paths use the current working directory. | **true** | - |
| **`checksum`** | Expected SHA-256 of the archive bytes, as 64 lowercase hexadecimal characters. | **true** | - |
| **`sign`** | Sign the published OCI chart using Cosign and GitHub Actions OIDC. | **false** | `true` |
| | Enabled by default. Set to `false` to opt out. | | |
| | Requires `id-token: write` and write access to the OCI registry. | | |
| | Does not generate a Helm PGP provenance (.prov) file. | | |
| **Input** | **Description** | **Required** | **Default** |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | --------------------------------- |
| **`oci-registry`** | OCI registry where to push chart. | **true** | `ghcr.io` |
| **`oci-registry-username`** | OCI registry username. | **true** | `${{ github.repository_owner }}` |
| **`oci-registry-password`** | OCI registry password. | **true** | `${{ github.token }}` |
| **`oci-repository`** | OCI namespace without the registry or final chart name. | **false** | `${{ github.repository }}/charts` |
| | Defaults to {owner}/{repository}/charts. The archive supplies its chart name/version. | | |
| | Set this explicitly to preserve a different publication namespace. | | |
| **`archive`** | Path to the prepared .tgz archive. Relative paths use the current working directory. Mutually exclusive with artifact-id and archive-name. | **false** | - |
| **`artifact-id`** | One immutable artifact ID from this workflow run, such as helm-chart-ci's artifact-id output. Requires archive-name; mutually exclusive with archive. | **false** | - |
| **`archive-name`** | Prepared .tgz basename inside the artifact, such as helm-chart-ci's archive-name output. Required only with artifact-id. | **false** | - |
| **`checksum`** | Expected SHA-256 of the archive bytes, as 64 lowercase hexadecimal characters. | **true** | - |
| **`sign`** | Sign the published OCI chart using Cosign and GitHub Actions OIDC. | **false** | `true` |
| | Enabled by default. Set to `false` to opt out. | | |
| | Requires `id-token: write` and write access to the OCI registry. | | |
| | Does not generate a Helm PGP provenance (.prov) file. | | |

<!-- inputs:end -->
<!-- secrets:start -->
Expand Down Expand Up @@ -102,7 +109,7 @@ This documentation was automatically generated by [CI Dokumentor](https://github
## Usage

```yaml
- uses: hoverkraft-tech/ci-github-container/actions/helm/release-chart@3feb56e45f82273a7eded46ac3b9364c08337cee # 3.0.0
- uses: hoverkraft-tech/ci-github-container/actions/helm/release-chart@733a81feaab09ff9918cacc4f22f30c254e10527 # feat/helm-release-artifact-input
with:
# OCI registry where to push chart.
#
Expand All @@ -129,10 +136,15 @@ This documentation was automatically generated by [CI Dokumentor](https://github
# Default: `${{ github.repository }}/charts`
oci-repository: ${{ github.repository }}/charts

# Path to the prepared .tgz archive. Relative paths use the current working directory.
# This input is required.
# Path to the prepared .tgz archive. Relative paths use the current working directory. Mutually exclusive with artifact-id and archive-name.
archive: ""

# One immutable artifact ID from this workflow run, such as helm-chart-ci's artifact-id output. Requires archive-name; mutually exclusive with archive.
artifact-id: ""

# Prepared .tgz basename inside the artifact, such as helm-chart-ci's archive-name output. Required only with artifact-id.
archive-name: ""

# Expected SHA-256 of the archive bytes, as 64 lowercase hexadecimal characters.
# This input is required.
checksum: ""
Expand Down
Loading
Loading