Initial commit: Full Crawl API implementation
This commit is contained in:
88
.github/workflows/deploy.yml
vendored
Normal file
88
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
|
||||
env:
|
||||
KUBECONFIG: ${{ github.workspace }}/kubeconfig
|
||||
|
||||
jobs:
|
||||
deploy-staging:
|
||||
name: Deploy to Staging
|
||||
runs-on: ubuntu-latest
|
||||
environment: staging
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
with:
|
||||
version: 'v1.29.0'
|
||||
|
||||
- name: Setup Helm
|
||||
uses: azure/setup-helm@v4
|
||||
with:
|
||||
version: '3.14.0'
|
||||
|
||||
- name: Configure kubectl
|
||||
run: |
|
||||
echo "${{ secrets.KUBE_CONFIG_STAGING }}" | base64 -d > kubeconfig
|
||||
|
||||
- name: Deploy to staging
|
||||
run: |
|
||||
kubectl set image deployment/api api=crawlapi/api:${{ github.sha }} -n crawlapi-staging
|
||||
kubectl set image deployment/worker worker=crawlapi/worker:${{ github.sha }} -n crawlapi-staging
|
||||
kubectl set image deployment/frontend frontend=crawlapi/frontend:${{ github.sha }} -n crawlapi-staging
|
||||
kubectl rollout status deployment/api -n crawlapi-staging --timeout=300s
|
||||
kubectl rollout status deployment/worker -n crawlapi-staging --timeout=300s
|
||||
|
||||
- name: Run smoke tests
|
||||
run: |
|
||||
curl -sf https://staging.crawlapi.dev/metrics || exit 1
|
||||
curl -sf -X POST https://staging.crawlapi.dev/api/content \
|
||||
-H "x-api-key: ${{ secrets.STAGING_API_KEY }}" \
|
||||
-d '{"url":"https://example.com"}' || exit 1
|
||||
|
||||
deploy-production:
|
||||
name: Deploy to Production
|
||||
needs: deploy-staging
|
||||
runs-on: ubuntu-latest
|
||||
environment: production
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
with:
|
||||
version: 'v1.29.0'
|
||||
|
||||
- name: Configure kubectl
|
||||
run: |
|
||||
echo "${{ secrets.KUBE_CONFIG_PRODUCTION }}" | base64 -d > kubeconfig
|
||||
|
||||
- name: Deploy to production
|
||||
run: |
|
||||
kubectl set image deployment/api api=crawlapi/api:${{ github.sha }} -n crawlapi
|
||||
kubectl set image deployment/worker worker=crawlapi/worker:${{ github.sha }} -n crawlapi
|
||||
kubectl set image deployment/frontend frontend=crawlapi/frontend:${{ github.sha }} -n crawlapi
|
||||
kubectl rollout status deployment/api -n crawlapi --timeout=300s
|
||||
kubectl rollout status deployment/worker -n crawlapi --timeout=300s
|
||||
|
||||
- name: Verify deployment
|
||||
run: |
|
||||
kubectl get pods -n crawlapi
|
||||
curl -sf https://api.crawlapi.dev/metrics || exit 1
|
||||
|
||||
- name: Notify on failure
|
||||
if: failure()
|
||||
uses: slackapi/slack-github-action@v1
|
||||
with:
|
||||
payload: |
|
||||
{
|
||||
"text": "🚨 Production deploy failed for Crawl API ${{ github.sha }}"
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
Reference in New Issue
Block a user