-
Notifications
You must be signed in to change notification settings - Fork 180
Add automated blog image workflow #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
685e344
Add automated blog image workflow
haacked 75eae84
Fix critical security vulnerabilities and improve blog workflow scripts
haacked c63aa51
Address Copilot code review feedback
haacked 23e68ee
Add comprehensive unit test suite with BATS
haacked 337e6f1
Fix unit test failures and improve cross-platform compatibility
haacked 68b861c
Add GitHub Actions workflow for automated testing
haacked 6c291c8
Fix editor validation test for cross-platform compatibility
haacked 15e1926
Remove duplicate CI runs on feature branches
haacked 3373911
Fix security issues and improve code organization
haacked 6fd6c95
Add batch mode to generate-images and fix documentation
haacked 8e51176
Fix security issues from code review
haacked d16c7e5
Make image file validation case-insensitive for cross-platform compat…
haacked File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Blog Image Workflow Configuration | ||
| # Copy this file to .blog-config.yml and fill in your API keys | ||
|
|
||
| # OpenAI API key for DALL-E image generation | ||
| # Get your key from: https://platform.openai.com/api-keys | ||
| OPENAI_API_KEY="sk-your-api-key-here" | ||
|
|
||
| # TinyPNG API key for image optimization (optional) | ||
| # Get your key from: https://tinypng.com/developers | ||
| # If not provided, will use ImageMagick for local optimization | ||
| TINYPNG_API_KEY="" | ||
|
|
||
| # Path to your images repository | ||
| # This should point to the local clone of github.com/haacked/images | ||
| IMAGES_REPO_PATH="$HOME/dev/haacked/images" | ||
|
|
||
| # Base URL for published images | ||
| IMAGE_BASE_URL="https://i.haacked.com" | ||
|
|
||
| # Optional: Editor command to open new posts | ||
| # Examples: "code", "vim", "subl", etc. | ||
| # Leave empty to skip auto-opening | ||
| EDITOR="" | ||
|
|
||
| # DALL-E image generation settings | ||
| DALLE_MODEL="dall-e-3" | ||
| DALLE_SIZE="1024x1024" # Options: 1024x1024, 1792x1024, 1024x1792 | ||
| DALLE_QUALITY="standard" # Options: standard, hd | ||
| DALLE_STYLE="vivid" # Options: vivid, natural |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Test Blog Scripts | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install BATS | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y bats | ||
|
|
||
| - name: Run tests | ||
| run: bin/test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env bash | ||
| # Run all tests for blog workflow scripts | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Get script directory | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
|
|
||
| # Colors | ||
| GREEN='\033[0;32m' | ||
| RED='\033[0;31m' | ||
| YELLOW='\033[1;33m' | ||
| NC='\033[0m' | ||
|
|
||
| echo -e "${GREEN}Running blog workflow tests...${NC}\n" | ||
|
|
||
| # Check if bats is installed | ||
| if ! command -v bats > /dev/null 2>&1; then | ||
| echo -e "${RED}Error: bats is not installed${NC}" | ||
| echo "Install with: brew install bats-core" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Run unit tests | ||
| echo -e "${YELLOW}=== Unit Tests ===${NC}" | ||
| if bats "$ROOT_DIR/tests/unit/"*.bats; then | ||
| echo -e "\n${GREEN}✓ All unit tests passed!${NC}\n" | ||
| else | ||
| echo -e "\n${RED}✗ Some unit tests failed${NC}\n" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Run integration tests if they exist | ||
| if [ -d "$ROOT_DIR/tests/integration" ] && [ -n "$(ls -A "$ROOT_DIR/tests/integration"/*.bats 2> /dev/null)" ]; then | ||
| echo -e "${YELLOW}=== Integration Tests ===${NC}" | ||
| if bats "$ROOT_DIR/tests/integration/"*.bats; then | ||
| echo -e "\n${GREEN}✓ All integration tests passed!${NC}\n" | ||
| else | ||
| echo -e "\n${RED}✗ Some integration tests failed${NC}\n" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo -e "${GREEN}========================================${NC}" | ||
| echo -e "${GREEN}All tests passed! ✓${NC}" | ||
| echo -e "${GREEN}========================================${NC}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name
batsinstalled via apt-get may not be the correct BATS package. On Ubuntu/Debian, the correct package for BATS (Bash Automated Testing System) is typicallybats(older versions) orbats-core(newer versions). Thebin/testscript referencesbats-corein its installation instructions (line 21), but the workflow installsbats. These should be consistent. Consider usingbatsfor Ubuntu's default package, or document which version is expected.