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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CODEOWNERS
# Repository owners: update if needed
* @Think-Cube/think-cube
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Bug Report
description: Report a problem with a reusable workflow
title: "bug: "
labels: ["bug", "triage"]
body:
- type: input
id: workflow
attributes:
label: Workflow and version
placeholder: e.g. container-image.yml@v1.0.0
validations:
required: true

- type: input
id: run
attributes:
label: Link to the failing run
validations:
required: true

- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear description of what the bug is.
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected behavior
validations:
required: true
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Feature Request
description: Suggest an improvement or a new reusable workflow
title: "feat: "
labels: ["enhancement", "triage"]
body:
- type: textarea
id: problem
attributes:
label: Problem / motivation
description: What problem does this solve? What use case does it enable?
validations:
required: true

- type: textarea
id: solution
attributes:
label: Proposed solution
validations:
required: true

- type: textarea
id: alternatives
attributes:
label: Alternatives considered
validations:
required: false
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Type of Change

- [ ] Bug fix
- [ ] New feature / improvement
- [ ] Action / dependency update
- [ ] Documentation update
- [ ] Other (describe below)

## Description

<!-- What does this PR change and why? -->

## Testing

- [ ] `actionlint` passes
- [ ] Ran the changed workflow from a calling repository
- [ ] No secrets or credentials committed

## Checklist

- [ ] Actions are pinned to commit SHAs
- [ ] Breaking changes to inputs, secrets or permissions are called out
- [ ] README updated if behavior changed
- [ ] I have read [CONTRIBUTING.md](../CONTRIBUTING.md)
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns:
- "*"
210 changes: 210 additions & 0 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
name: Container image

on:
workflow_call:
inputs:
image-name:
description: Image name without registry or namespace
required: true
type: string
context:
description: Build context
required: false
type: string
default: .
dockerfile:
description: Path to the Dockerfile
required: false
type: string
default: Dockerfile
platforms:
description: JSON array of platforms to build
required: false
type: string
default: '["linux/amd64", "linux/arm64"]'
smoke-test:
description: Script run with the image reference as its only argument
required: false
type: string
default: tests/smoke.sh
trivy-severity:
description: Severities that fail the build
required: false
type: string
default: CRITICAL
dockerhub-namespace:
description: Docker Hub namespace of the mirror
required: false
type: string
default: thinkcubedev
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false

permissions: {}

jobs:
lint:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: hadolint/hadolint-action@06be81baf89a55ffd0e24b8f04a4185738dd3387 # v3.5.0
with:
dockerfile: ${{ inputs.dockerfile }}

verify:
needs: lint
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(inputs.platforms) }}
env:
IMAGE: local/${{ inputs.image-name }}:test
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: ${{ matrix.platform }}
load: true
tags: ${{ env.IMAGE }}
provenance: false
no-cache: ${{ github.event_name == 'schedule' }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }},ignore-error=true
- name: Run smoke test
env:
SMOKE_TEST: ${{ inputs.smoke-test }}
run: bash "$SMOKE_TEST" "$IMAGE"
- uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.IMAGE }}
scanners: vuln
severity: ${{ inputs.trivy-severity }}
ignore-unfixed: true
exit-code: "1"
timeout: 15m

publish:
needs: verify
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
packages: write
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Resolve image references
id: image
env:
IMAGE_NAME: ${{ inputs.image-name }}
PLATFORMS: ${{ inputs.platforms }}
run: |
{
echo "ghcr=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE_NAME}"
echo "platforms=$(jq -r 'join(",")' <<< "$PLATFORMS")"
echo 'cache-from<<CACHE'
jq -r '.[] | "type=gha,scope=\(.)"' <<< "$PLATFORMS"
echo CACHE
} >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
if: env.DOCKERHUB_USERNAME != ''
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
id: meta
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
with:
images: ${{ steps.image.outputs.ghcr }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge,branch=main
type=sha,format=short,prefix=sha-,enable=${{ github.event_name == 'push' && github.ref_type == 'branch' }}
type=schedule,pattern={{date 'YYYYMMDD'}},prefix=edge-
- name: Refuse to overwrite a released version
if: github.ref_type == 'tag'
env:
IMAGE: ${{ steps.image.outputs.ghcr }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
if docker buildx imagetools inspect "$IMAGE:$VERSION" > /dev/null 2>&1; then
echo "::error::$IMAGE:$VERSION already exists; release a new version instead"
exit 1
fi
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
id: build
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: ${{ steps.image.outputs.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
sbom: true
provenance: mode=max
no-cache: ${{ github.event_name == 'schedule' }}
cache-from: ${{ steps.image.outputs.cache-from }}
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532 # v4.1.3
- name: Sign the image
env:
IMAGE: ${{ steps.image.outputs.ghcr }}
DIGEST: ${{ steps.build.outputs.digest }}
run: cosign sign --yes "$IMAGE@$DIGEST"
- name: Mirror to Docker Hub
if: env.DOCKERHUB_USERNAME != ''
env:
GHCR_IMAGE: ${{ steps.image.outputs.ghcr }}
HUB_IMAGE: docker.io/${{ inputs.dockerhub-namespace }}/${{ inputs.image-name }}
DIGEST: ${{ steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
args=()
while read -r tag; do
args+=(--tag "${tag/#$GHCR_IMAGE/$HUB_IMAGE}")
done <<< "$TAGS"
docker buildx imagetools create "${args[@]}" "$GHCR_IMAGE@$DIGEST"
cosign sign --yes "$HUB_IMAGE@$DIGEST"
- name: Write summary
env:
IMAGE: ${{ steps.image.outputs.ghcr }}
DIGEST: ${{ steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
{
echo "Published \`$IMAGE@$DIGEST\`"
echo
while read -r tag; do
echo "- \`$tag\`"
done <<< "$TAGS"
} >> "$GITHUB_STEP_SUMMARY"
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions: {}

jobs:
actionlint:
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: docker://rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667
with:
args: -color
41 changes: 41 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes
- Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior:

- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at the repository's Issues page. All complaints will be reviewed and investigated promptly and fairly.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
Loading