diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..4586d25 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy to Cloudflare Pages + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Build ailog + run: | + cargo build --release + + - name: Build OAuth app + run: | + cd oauth + npm install + npm run build + + - name: Copy OAuth assets + run: | + cp -r oauth/dist/* my-blog/static/ + + - name: Generate site with ailog + run: | + ./target/release/ailog generate --input content --output my-blog/public + + - name: Deploy to Cloudflare Pages + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: syui-ai + directory: my-blog/public + gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitea/workflows/example-usage.yml b/.gitea/workflows/example-usage.yml new file mode 100644 index 0000000..ddc7bff --- /dev/null +++ b/.gitea/workflows/example-usage.yml @@ -0,0 +1,28 @@ +name: Example ailog usage + +on: + workflow_dispatch: # Manual trigger for testing + +jobs: + build-with-ailog-action: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build with ailog action + uses: ai/log@v1 # This will reference this repository + with: + content-dir: 'content' + output-dir: 'public' + ai-integration: true + atproto-integration: true + + - name: Deploy to Cloudflare Pages + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: my-blog + directory: public \ No newline at end of file diff --git a/README.md b/README.md index bc830cc..6e06672 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,35 @@ AI-powered static blog generator with ATProto integration, part of the ai.ai ecosystem. +## 🎯 Gitea Action Usage + +Use ailog in your Gitea Actions workflow: + +```yaml +name: Deploy Blog +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ai/log@v1 + with: + content-dir: 'content' + output-dir: 'public' + ai-integration: true + atproto-integration: true + - uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: my-blog + directory: public +``` + ## 🚀 Quick Start ### Development Setup diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b8b6510 --- /dev/null +++ b/action.yml @@ -0,0 +1,108 @@ +name: 'ailog Static Site Generator' +description: 'AI-powered static blog generator with atproto integration' +author: 'syui' + +branding: + icon: 'book-open' + color: 'orange' + +inputs: + content-dir: + description: 'Content directory containing markdown files' + required: false + default: 'content' + output-dir: + description: 'Output directory for generated site' + required: false + default: 'public' + template-dir: + description: 'Template directory' + required: false + default: 'templates' + static-dir: + description: 'Static assets directory' + required: false + default: 'static' + config-file: + description: 'Configuration file path' + required: false + default: 'ailog.toml' + ai-integration: + description: 'Enable AI features' + required: false + default: 'true' + atproto-integration: + description: 'Enable atproto/OAuth features' + required: false + default: 'true' + +outputs: + site-url: + description: 'Generated site URL' + value: ${{ steps.generate.outputs.site-url }} + build-time: + description: 'Build time in seconds' + value: ${{ steps.generate.outputs.build-time }} + +runs: + using: 'composite' + steps: + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install ailog + shell: bash + run: | + if [ ! -f "./target/release/ailog" ]; then + cargo build --release + fi + + - name: Setup Node.js for OAuth app + if: ${{ inputs.atproto-integration == 'true' }} + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Build OAuth app + if: ${{ inputs.atproto-integration == 'true' }} + shell: bash + run: | + if [ -d "oauth" ]; then + cd oauth + npm install + npm run build + cp -r dist/* ../${{ inputs.static-dir }}/ + fi + + - name: Generate site + id: generate + shell: bash + run: | + start_time=$(date +%s) + + ./target/release/ailog generate \ + --input ${{ inputs.content-dir }} \ + --output ${{ inputs.output-dir }} \ + --templates ${{ inputs.template-dir }} \ + --static ${{ inputs.static-dir }} \ + --config ${{ inputs.config-file }} + + end_time=$(date +%s) + build_time=$((end_time - start_time)) + + echo "build-time=${build_time}" >> $GITHUB_OUTPUT + echo "site-url=file://$(pwd)/${{ inputs.output-dir }}" >> $GITHUB_OUTPUT + + - name: Display build summary + shell: bash + run: | + echo "✅ ailog build completed successfully" + echo "📁 Output directory: ${{ inputs.output-dir }}" + echo "⏱️ Build time: ${{ steps.generate.outputs.build-time }}s" + if [ -d "${{ inputs.output-dir }}" ]; then + echo "📄 Generated files:" + find ${{ inputs.output-dir }} -type f | head -10 + fi \ No newline at end of file