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
134 changes: 134 additions & 0 deletions .github/workflows/generate-gh-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Generate Feature from gh-release Template

on:
workflow_dispatch:
inputs:
ID:
description: 'Feature identifier (e.g., akamai-cli)'
required: true
type: string
Description:
description: 'Feature description'
required: true
type: string
Repository:
description: 'GitHub repository in format "owner/repo" (e.g., akamai/cli)'
required: true
type: string
BinaryNames:
description: 'Binary names (comma-separated if multiple)'
required: true
type: string
BinaryVersionCommands:
description: 'Version check commands (comma-separated if multiple)'
required: false
type: string
default: '--version'
BinaryNonLatestVersions:
description: 'Non-latest versions for testing (comma-separated if multiple)'
required: true
type: string

jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.ARCHIVE_TOKEN }}

- name: Check if feature already exists
run: |
if [ -d "src/${{ inputs.ID }}" ] || [ -d "test/${{ inputs.ID }}" ]; then
echo "❌ Feature '${{ inputs.ID }}' already exists!"
echo "Please use a different feature ID or remove the existing feature first."
exit 1
fi
echo "✅ Feature ID is available"

- name: Validate GitHub repository exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh api repos/${{ inputs.Repository }} > /dev/null 2>&1; then
echo "✅ Repository '${{ inputs.Repository }}' exists and is accessible"
else
echo "⚠️ Warning: Could not verify repository '${{ inputs.Repository }}'"
echo "The repository might be private, not exist, or you don't have access to it."
echo "Continuing with feature generation..."
fi

- name: Download boilerplate
run: |
wget -q https://github.com/gruntwork-io/boilerplate/releases/download/v0.10.1/boilerplate_linux_amd64
chmod +x boilerplate_linux_amd64

- name: Create vars.yml
run: |
cat > vars.yml << 'EOF'
ID: ${{ inputs.ID }}
Description: ${{ inputs.Description }}
Repository: ${{ inputs.Repository }}
BinaryNames: ${{ inputs.BinaryNames }}
BinaryVersionCommands: ${{ inputs.BinaryVersionCommands }}
BinaryNonLatestVersions: ${{ inputs.BinaryNonLatestVersions }}
EOF
echo "📝 Created vars.yml:"
cat vars.yml

- name: Create branch for new feature
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b feature/${{ inputs.ID }}-init

- name: Generate feature files
run: |
echo "🔧 Generating feature files from templates/gh-release..."
./boilerplate_linux_amd64 \
--template-url templates/gh-release/ \
--output-folder src/${{ inputs.ID }} \
--var-file vars.yml \
--non-interactive

- name: Generate test files
run: |
echo "🧪 Generating test files from templates/test..."
./boilerplate_linux_amd64 \
--template-url templates/test/ \
--output-folder test/${{ inputs.ID }} \
--var-file vars.yml \
--non-interactive

- name: Commit changes
run: |
git add -A
git commit -m "feat(${{ inputs.ID }}): init

Generated using boilerplate templates."

- name: Push changes
run: git push origin feature/${{ inputs.ID }}-init

- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.ARCHIVE_TOKEN }}
run: |
gh pr create \
--title "feat(${{ inputs.ID }}): init" \
--body "## New Feature: \`${{ inputs.ID }}\`

**Description:** ${{ inputs.Description }}

**Repository:** [${{ inputs.Repository }}](https://github.com/${{ inputs.Repository }})

**Binaries:** \`${{ inputs.BinaryNames }}\`

**Version Commands:** \`${{ inputs.BinaryVersionCommands }}\`

**Test Versions:** \`${{ inputs.BinaryNonLatestVersions }}\`

---

This PR was automatically generated using the boilerplate templates.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions templates/bak/test/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"test_debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"<id>": {}
}
},
"test_specific_version": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"<id>": {
"version": "x.y.z"
}
}
}
}
9 changes: 9 additions & 0 deletions templates/bak/test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

source dev-container-features-test-lib

check "something is installed" something --version

reportResults
9 changes: 9 additions & 0 deletions templates/bak/test/test_debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

source dev-container-features-test-lib

check "something is installed" something --version

reportResults
9 changes: 9 additions & 0 deletions templates/bak/test/test_specific_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

source dev-container-features-test-lib

check "something version is equal to x.y.z" sh -c "something --version | grep 'x.y.z'"

reportResults
12 changes: 12 additions & 0 deletions templates/gh-release/boilerplate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
variables:
- name: ID
description: The unique identifier for the feature (e.g., akamai-cli).

- name: Description
description: A brief description of the feature.

- name: Repository
description: The GitHub repository in the format "owner/repo" (e.g., akamai/cli).

- name: BinaryNames
description: The names of the binaries to install from the release (comma-separated if multiple).
18 changes: 18 additions & 0 deletions templates/gh-release/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": "{{.ID}}",
"version": "1.0.0",
"name": "{{.ID}} (via Github Releases)",
"documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/{{.ID}}",
"description": "{{.Description}}",
"options": {
"version": {
"default": "latest",
"description": "Select the version to install.",
"proposals": [
"latest"
],
"type": "string"
}
},
"installsAfter": []
}
21 changes: 21 additions & 0 deletions templates/gh-release/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -e

source ./library_scripts.sh

# nanolayer is a cli utility which keeps container layers as small as possible
# source code: https://github.com/devcontainers-extra/nanolayer
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
# and if missing - will download a temporary copy that automatically get deleted at the end
# of the script
ensure_nanolayer nanolayer_location "v0.5.6"

# Example nanolayer installation via devcontainer-feature
$nanolayer_location \
install \
devcontainer-feature \
"ghcr.io/devcontainers-extra/features/gh-release:1" \
--option repo='{{.Repository}}' --option binaryNames='{{.BinaryNames}}' --option version="$VERSION"

echo 'Done!'
Loading