Skip to content

Commit 8da663e

Browse files
authored
Merge pull request #75 from SupportTools/add-unix-signals-blog-post
Migrate to Cloudflare Workers & Add Advanced Linux Programming Blog Posts
2 parents 5bd68b2 + e09a163 commit 8da663e

File tree

56 files changed

+65195
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+65195
-6
lines changed

.github/workflows/README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains automated workflows for the Support Tools website.
4+
5+
## Workflows
6+
7+
### 1. cloudflare-workers.yml - Cloudflare Workers Deployment
8+
9+
**Purpose**: Deploy the Hugo static site to Cloudflare Workers
10+
11+
**Triggers**:
12+
- **Push to main**: Deploys to staging, then production
13+
- **Pull Request**: Deploys to development for preview
14+
- **Manual dispatch**: Deploy to any specific environment
15+
- **Schedule**: Daily at midnight UTC (content refresh)
16+
17+
**Deployment Flow**:
18+
19+
```mermaid
20+
graph TD
21+
A[Trigger] --> B[Test/Build Hugo]
22+
B --> C{Branch?}
23+
C -->|PR| D[Deploy to Dev]
24+
C -->|main| E[Deploy to Staging]
25+
E --> F[Deploy to Production]
26+
C -->|manual| G[Deploy to Selected Env]
27+
```
28+
29+
**Environments**:
30+
- `development` - https://dev.support.tools
31+
- `mst` - https://mst.support.tools
32+
- `qas` - https://qas.support.tools
33+
- `tst` - https://tst.support.tools
34+
- `staging` - https://stg.support.tools
35+
- `production` - https://support.tools
36+
37+
**Environment Protection**:
38+
- Production requires manual approval
39+
- Staging auto-deploys from main branch
40+
- Development auto-deploys for PRs
41+
42+
### 2. pipeline.yml - Legacy Kubernetes Deployment (Deprecated)
43+
44+
**Status**: DEPRECATED - Use cloudflare-workers.yml instead
45+
46+
**Purpose**: Previously deployed to Kubernetes clusters via ArgoCD
47+
48+
## Required Secrets
49+
50+
Configure these in Settings → Secrets → Actions:
51+
52+
- `CLOUDFLARE_API_TOKEN` - API token with Workers:Edit permissions
53+
54+
## Usage Examples
55+
56+
### Manual Deployment
57+
58+
1. Go to Actions tab
59+
2. Select "Deploy to Cloudflare Workers"
60+
3. Click "Run workflow"
61+
4. Select environment
62+
5. Click "Run workflow"
63+
64+
### Automatic Deployments
65+
66+
- **Production**: Push to `main` branch
67+
- **Development**: Create a pull request
68+
- **Daily refresh**: Automatic at midnight UTC
69+
70+
## Monitoring Deployments
71+
72+
### View Logs
73+
```bash
74+
# Real-time logs
75+
wrangler tail --env production
76+
77+
# GitHub Actions logs
78+
gh run list --workflow=cloudflare-workers.yml
79+
gh run view <run-id>
80+
```
81+
82+
### Check Status
83+
```bash
84+
# Check all environments
85+
for env in dev mst qas tst stg ""; do
86+
url="https://${env}${env:+.}support.tools"
87+
echo -n "$url: "
88+
curl -s -o /dev/null -w "%{http_code}\n" $url
89+
done
90+
```
91+
92+
## Rollback Procedure
93+
94+
1. **Via GitHub**:
95+
```bash
96+
# List recent deployments
97+
gh run list --workflow=cloudflare-workers.yml --limit 10
98+
99+
# Re-run a previous successful deployment
100+
gh run rerun <run-id>
101+
```
102+
103+
2. **Via Wrangler**:
104+
```bash
105+
# List versions
106+
wrangler deployments list
107+
108+
# Rollback to previous version
109+
wrangler rollback --env production
110+
```
111+
112+
## Troubleshooting
113+
114+
### Deployment Fails
115+
116+
1. Check GitHub Actions logs
117+
2. Verify CLOUDFLARE_API_TOKEN is set
118+
3. Check Hugo build output
119+
4. Verify DNS is pointing to Cloudflare
120+
121+
### Site Not Updating
122+
123+
1. Clear Cloudflare cache
124+
2. Check if deployment completed
125+
3. Verify correct environment deployed
126+
4. Check Workers logs: `wrangler tail`
127+
128+
### Performance Issues
129+
130+
1. Check Workers analytics in Cloudflare Dashboard
131+
2. Monitor request duration in logs
132+
3. Verify static assets are cached
133+
4. Check for large unoptimized images
134+
135+
## Migration from Kubernetes
136+
137+
The site has been migrated from Kubernetes to Cloudflare Workers:
138+
139+
- **Old**: Docker → Kubernetes → ArgoCD → Nginx
140+
- **New**: Hugo → Cloudflare Workers → Global CDN
141+
142+
Benefits:
143+
- ✅ Free hosting for static assets
144+
- ✅ Global edge deployment
145+
- ✅ No infrastructure to manage
146+
- ✅ Faster deployment times
147+
- ✅ Better performance
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Deployment Notifications
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Deploy to Cloudflare Workers"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
notify:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
13+
14+
steps:
15+
- name: Get workflow details
16+
id: workflow-details
17+
run: |
18+
echo "status=${{ github.event.workflow_run.conclusion }}" >> $GITHUB_OUTPUT
19+
echo "run_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
20+
echo "actor=${{ github.event.workflow_run.actor.login }}" >> $GITHUB_OUTPUT
21+
echo "branch=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
22+
23+
# Uncomment and configure for Slack notifications
24+
# - name: Slack Notification
25+
# if: ${{ vars.SLACK_WEBHOOK_URL != '' }}
26+
# uses: 8398a7/action-slack@v3
27+
# with:
28+
# status: ${{ github.event.workflow_run.conclusion }}
29+
# webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
30+
# text: |
31+
# Deployment ${{ github.event.workflow_run.conclusion == 'success' && '✅ succeeded' || '❌ failed' }}
32+
# Branch: ${{ steps.workflow-details.outputs.branch }}
33+
# Actor: ${{ steps.workflow-details.outputs.actor }}
34+
# Run: https://github.com/${{ github.repository }}/actions/runs/${{ steps.workflow-details.outputs.run_id }}
35+
36+
# Uncomment and configure for Discord notifications
37+
# - name: Discord Notification
38+
# if: ${{ vars.DISCORD_WEBHOOK_URL != '' }}
39+
# uses: sarisia/actions-status-discord@v1
40+
# with:
41+
# webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
42+
# status: ${{ github.event.workflow_run.conclusion }}
43+
# title: "Support Tools Deployment"
44+
# description: |
45+
# **Status**: ${{ github.event.workflow_run.conclusion == 'success' && '✅ Success' || '❌ Failed' }}
46+
# **Branch**: ${{ steps.workflow-details.outputs.branch }}
47+
# **Triggered by**: ${{ steps.workflow-details.outputs.actor }}
48+
# url: "https://github.com/${{ github.repository }}/actions/runs/${{ steps.workflow-details.outputs.run_id }}"
49+
50+
# Uncomment and configure for email notifications
51+
# - name: Send email notification
52+
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
53+
# uses: dawidd6/action-send-mail@v3
54+
# with:
55+
# server_address: smtp.gmail.com
56+
# server_port: 587
57+
# username: ${{ secrets.MAIL_USERNAME }}
58+
# password: ${{ secrets.MAIL_PASSWORD }}
59+
# subject: "❌ Support Tools Deployment Failed"
60+
61+
# from: GitHub Actions
62+
# body: |
63+
# Deployment to Cloudflare Workers has failed.
64+
#
65+
# Branch: ${{ steps.workflow-details.outputs.branch }}
66+
# Actor: ${{ steps.workflow-details.outputs.actor }}
67+
#
68+
# View details: https://github.com/${{ github.repository }}/actions/runs/${{ steps.workflow-details.outputs.run_id }}
69+
70+
- name: Create GitHub Issue on Failure
71+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
72+
uses: actions/github-script@v7
73+
with:
74+
script: |
75+
const issue = await github.rest.issues.create({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
title: `🚨 Deployment Failed - ${new Date().toISOString().split('T')[0]}`,
79+
body: `## Deployment Failure
80+
81+
The Cloudflare Workers deployment has failed.
82+
83+
**Details:**
84+
- Branch: \`${{ steps.workflow-details.outputs.branch }}\`
85+
- Triggered by: @${{ steps.workflow-details.outputs.actor }}
86+
- Workflow Run: [View Details](https://github.com/${{ github.repository }}/actions/runs/${{ steps.workflow-details.outputs.run_id }})
87+
88+
**Action Required:**
89+
1. Check the workflow logs
90+
2. Fix the issue
91+
3. Re-run the deployment
92+
93+
cc: @${{ steps.workflow-details.outputs.actor }}`,
94+
labels: ['deployment-failure', 'urgent']
95+
});
96+
97+
console.log(`Created issue #${issue.data.number}`);

0 commit comments

Comments
 (0)