Skip to content

Commit

Permalink
build: implementing solution library workflow support
Browse files Browse the repository at this point in the history
  • Loading branch information
drduhe committed Nov 29, 2024
1 parent 3ed63b6 commit 82679fd
Show file tree
Hide file tree
Showing 4 changed files with 983 additions and 830 deletions.
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CODEOWNERS file to define ownership for solution repository

# Default owner for all files in the repository
* @aws-solutions-library-samples/maintainers

# Explicit owner for the maintainer workflows configuration
/.github/workflows/maintainer_workflows.yml @aws-solutions-library-samples/maintainers

# Explicit owner for the solution ID validator script
/.github/solutionid_validator.sh @aws-solutions-library-samples/maintainers
36 changes: 36 additions & 0 deletions .github/solutionid_validator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Exit immediately if any command exits with a non-zero status
set -euo pipefail

# Function to display usage information
usage() {
echo "Usage: $0 <solution_id>"
echo "Example: $0 ABC123"
exit 1
}

# Ensure a solution ID is provided as an argument
if [ "$#" -ne 1 ]; then
echo "Error: Missing solution ID."
usage
fi

# Assign the solution ID to a variable
SOLUTION_ID="$1"

# Output a message about what the script is checking
echo "Checking for solution ID: $SOLUTION_ID"

# Perform the search, excluding the '.github' directory
SEARCH_RESULT=$(grep -nr --exclude-dir='.github' "$SOLUTION_ID" ./.. || true)

# Check if the search result is non-empty
if [ -n "$SEARCH_RESULT" ]; then
echo -e "Solution ID '$SOLUTION_ID' found:\n"
echo "$SEARCH_RESULT"
exit 0
else
echo "Solution ID '$SOLUTION_ID' not found."
exit 1
fi
39 changes: 39 additions & 0 deletions .github/workflows/maintainer_workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Workflows managed by aws-solutions-library-samples maintainers
name: Maintainer Workflows

on:
# Trigger workflows on push or pull request events for the "main" branch
push:
branches:
- "main"
pull_request:
branches:
- "main"
types:
- opened
- reopened
- edited

jobs:
CheckSolutionId:
name: Validate Solution ID
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

# Step 2: Validate Solution ID using the script
- name: Validate Solution ID
run: |
# Ensure the script is executable
chmod +x ./.github/solutionid_validator.sh
# Run the solution ID validator script with the provided solution ID
./.github/solutionid_validator.sh "${{ vars.SOLUTIONID }}"
# Optional Step: Handle failures explicitly
- name: Handle Failure (optional)
if: failure()
run: |
echo "Solution ID validation failed. Please ensure the SOLUTIONID is correct."
Loading

0 comments on commit 82679fd

Please sign in to comment.