From 0933cf2bf51a1d47b4ccbc17ede7b42ba4a07467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=BChl?= Date: Mon, 16 Feb 2026 11:05:35 +0100 Subject: [PATCH] Initial commit: deploy-site action --- .gitignore | 2 ++ README.md | 61 +++++++++++++++++++++++++++++++++++++++++ deploy-site/action.yaml | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 deploy-site/action.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4570995 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.tar.gz +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..afd7bbb --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# CI Actions + +Reusable Forgejo/Gitea actions for toph's infrastructure. + +## Available Actions + +### `deploy-site` + +Deploy a static site to production. + +**Usage:** + +```yaml +name: Deploy +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + + - name: Build site (if needed) + run: npm run build + + - name: Deploy + uses: https://git.toph.so/toph/ci-actions/deploy-site@main + with: + site-name: mysite + source-dir: dist # optional, defaults to current dir +``` + +**What it does:** +- Packages your site +- Uploads to deployment server +- Triggers Nomad deployment +- Site becomes available at `https://{site-name}.toph.so` + +**No configuration needed** - infrastructure handles: +- Docker images +- Resource limits +- Domains & SSL +- Load balancing + +## Development + +To add a new action: + +```bash +mkdir -p new-action +cd new-action +vim action.yaml +``` + +Then commit and push to `main`. + +## License + +MIT diff --git a/deploy-site/action.yaml b/deploy-site/action.yaml new file mode 100644 index 0000000..44f24b9 --- /dev/null +++ b/deploy-site/action.yaml @@ -0,0 +1,50 @@ +name: Deploy Site +description: Deploy a static site to production + +inputs: + site-name: + description: 'Site identifier (determines URL and deployment)' + required: true + + source-dir: + description: 'Directory containing the built site' + required: false + default: '.' + +runs: + using: composite + steps: + - name: Package site + shell: bash + run: | + echo "📦 Packaging ${{ inputs.site-name }}..." + cd "${{ inputs.source-dir }}" + tar czf /tmp/${{ inputs.site-name }}.tar.gz . + echo "✓ Packaged $(du -h /tmp/${{ inputs.site-name }}.tar.gz | cut -f1)" + + - name: Deploy via API + shell: bash + run: | + echo "🚀 Deploying ${{ inputs.site-name }}..." + + # TODO: Replace with actual deployment endpoint + # For now, use rsync + nomad dispatch + + # Extract to deployment location + ssh deploy@alvin "mkdir -p /var/www/sites/${{ inputs.site-name }}" + scp /tmp/${{ inputs.site-name }}.tar.gz deploy@alvin:/tmp/ + ssh deploy@alvin "cd /var/www/sites/${{ inputs.site-name }} && tar xzf /tmp/${{ inputs.site-name }}.tar.gz" + + # Trigger deployment + ssh deploy@alvin "nomad job dispatch -meta site=${{ inputs.site-name }} deploy-site" + + echo "✅ Deployed!" + + - name: Show deployment info + shell: bash + run: | + echo "" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "Site: ${{ inputs.site-name }}" + echo "URL: https://${{ inputs.site-name }}.toph.so" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"