Skip to content

Commit d0e74b6

Browse files
Merge pull request #1 from step-security/release
feat: onboarding actions-generate-metadata
2 parents 29f19a2 + c8da7b4 commit d0e74b6

19 files changed

Lines changed: 1377 additions & 1 deletion
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release GitHub Actions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Tag for the release"
8+
required: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
release:
15+
permissions:
16+
actions: read
17+
id-token: write
18+
contents: write
19+
20+
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
21+
with:
22+
tag: "${{ github.event.inputs.tag }}"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto Cherry-Pick from Upstream
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "Release GitHub Actions" ]
6+
types:
7+
- completed
8+
9+
workflow_dispatch:
10+
inputs:
11+
base_branch:
12+
description: "Base branch to create the PR against"
13+
required: true
14+
default: "main"
15+
mode:
16+
description: "Run mode: cherry-pick or verify"
17+
required: false
18+
default: "cherry-pick"
19+
20+
pull_request:
21+
types: [ opened, synchronize, labeled ]
22+
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
packages: read
27+
issues: write
28+
29+
jobs:
30+
cherry-pick:
31+
if: (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch' || contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'review-required')
32+
uses: step-security/reusable-workflows/.github/workflows/auto_cherry_pick.yaml@v1
33+
with:
34+
original-owner: "hashicorp"
35+
repo-name: "actions-generate-metadata"
36+
base_branch: ${{ inputs.base_branch || 'main' }}
37+
mode: ${{ github.event_name == 'pull_request' && 'verify' || inputs.mode || 'cherry-pick' }}

.github/workflows/docker.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish docker image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: 'Tag to release'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
if: startsWith(github.event.inputs.release_tag, 'v')
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@v2
22+
with:
23+
egress-policy: audit
24+
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
- name: Validate tag format
28+
run: |
29+
TAG=${{ github.event.inputs.release_tag }}
30+
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
31+
echo "❌ Invalid tag format: $TAG"
32+
exit 1
33+
fi
34+
echo "✅ Valid semver tag: $TAG"
35+
- name: Log in to GitHub Container Registry
36+
uses: step-security/docker-login-action@v4
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Set up QEMU for ARM builds
43+
uses: step-security/setup-qemu-action@v4
44+
45+
- name: Set up Docker Buildx
46+
uses: step-security/setup-buildx-action@v4
47+
48+
- name: Build and push Docker image
49+
uses: step-security/docker-build-push-action@v7
50+
with:
51+
context: .
52+
push: true
53+
platforms: linux/amd64,linux/arm64
54+
tags: |
55+
ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}

.github/workflows/test-action.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: test generate-metadata-action
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'README.md'
7+
- LICENSE
8+
9+
jobs:
10+
action-test-default:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
filepath: ${{ steps.action-run.outputs.filepath }}
14+
steps:
15+
- name: 'Checkout directory'
16+
uses: actions/checkout@v7
17+
- name: Generate metadata file
18+
id: generate_metadata
19+
uses: ./
20+
with:
21+
repository: ${{ github.event.repository.name }}
22+
version: make -f tests/Makefile version
23+
product: ${{ github.event.repository.name }}
24+
25+
action-test-provide-sha:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
filepath: ${{ steps.action-run.outputs.filepath }}
29+
steps:
30+
- name: 'Checkout directory'
31+
uses: actions/checkout@v7
32+
- name: Generate metadata file
33+
id: generate_metadata
34+
uses: ./
35+
with:
36+
repository: ${{ github.event.repository.name }}
37+
version: make -f tests/Makefile version
38+
product: ${{ github.event.repository.name }}
39+
sha: "6064764fb6b6213724fa55ce0fe737362ab97a12"
40+
metadataFileName: "metadata-sha-test.json"
41+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
action/action

.release/release-metadata.hcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright IBM Corp. 2021, 2025
2+
# Copyright 2026 StepSecurity
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
This file exists so that the metadata tests won't fail due to not seeing this file,
6+
which is expected to exist in a full workflow run.

.release/security-scan.hcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright IBM Corp. 2021, 2025
2+
# Copyright 2026 StepSecurity
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
This file exists so that the metadata tests won't fail due to not seeing this file,
6+
which is expected to exist in a full workflow run.

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright IBM Corp. 2021, 2025
2+
# Copyright 2026 StepSecurity
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
FROM golang:1.25 AS build
6+
LABEL maintainer="step-security security@stepsecurity.io"
7+
8+
# Copy all the action files into the container
9+
WORKDIR /go/src/action
10+
COPY action /go/src/action
11+
12+
# Enable Go modules
13+
ENV GO111MODULE=on
14+
RUN go mod download
15+
16+
# Compile the action
17+
RUN CGO_ENABLED=0 go build -o /action -ldflags="-s -w" .
18+
19+
FROM alpine:latest
20+
RUN apk --update add ca-certificates
21+
RUN apk add --no-cache git make bash
22+
23+
COPY --from=build /action /
24+
# Specify the container's entrypoint as the action
25+
ENTRYPOINT ["/action"]

0 commit comments

Comments
 (0)