Initial commit: deploy-site action
This commit is contained in:
commit
0933cf2bf5
3 changed files with 113 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*.tar.gz
|
||||
.DS_Store
|
||||
61
README.md
Normal file
61
README.md
Normal file
|
|
@ -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
|
||||
50
deploy-site/action.yaml
Normal file
50
deploy-site/action.yaml
Normal file
|
|
@ -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 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
Loading…
Add table
Reference in a new issue