Skip to content

Commit 344408f

Browse files
committed
feat: add dms with email trigger and docs
0 parents  commit 344408f

7 files changed

Lines changed: 1629 additions & 0 deletions

File tree

.github/workflows/dms.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Dead Man's Switch
2+
3+
permissions:
4+
contents: write
5+
6+
env:
7+
HEARTBEAT_INTERVAL: 336 # in hours, 2 weeks
8+
NUMBER_OF_WARNINGS: 2 # number of warnings before final action
9+
ARMED: "false"
10+
11+
on:
12+
schedule:
13+
- cron: '0 9 * * *' # Run daily at 09:00 UTC
14+
workflow_dispatch:
15+
inputs:
16+
heartbeat_interval:
17+
description: 'Heartbeat interval in hours'
18+
required: false
19+
number_of_warnings:
20+
description: 'Number of warnings before final action'
21+
required: false
22+
armed:
23+
description: 'Set to true to arm the switch, false for testing'
24+
required: false
25+
26+
jobs:
27+
run-dms:
28+
runs-on: ubuntu-22.04
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up Python 3.13
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: "3.13.5"
38+
39+
- name: Set Git user identity
40+
run: |
41+
git config --global user.email "dms@bot.github.com"
42+
git config --global user.name "dms_bot"
43+
44+
- name: Set up Git credentials
45+
run: |
46+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
47+
48+
- name: Set all variables and secrets as environment variables
49+
env:
50+
ALL_VARS: ${{ toJson(vars) }}
51+
ALL_SECRETS: ${{ toJson(secrets) }}
52+
run: |
53+
# Parse and export all variables
54+
echo "Setting up variables..."
55+
echo "$ALL_VARS" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
56+
57+
# Parse and export all secrets
58+
echo "Setting up secrets..."
59+
echo "$ALL_SECRETS" | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
60+
61+
echo "✅ All variables and secrets have been exported to environment"
62+
63+
- name: Run Dead Man's Switch
64+
run: |
65+
WORKFLOW_INPUT_HEARTBEAT_INTERVAL="${{ inputs.heartbeat_interval }}"
66+
WORKFLOW_INPUT_NUMBER_OF_WARNINGS="${{ inputs.number_of_warnings }}"
67+
WORKFLOW_INPUT_ARMED="${{ inputs.armed }}"
68+
69+
# Use input if provided, else check environment variables (with or without INPUT_ prefix), else fall back to DEFAULT
70+
HEARTBEAT_INTERVAL_ARG="${WORKFLOW_INPUT_HEARTBEAT_INTERVAL:-${HEARTBEAT_INTERVAL}}"
71+
NUMBER_OF_WARNINGS_ARG="${WORKFLOW_INPUT_NUMBER_OF_WARNINGS:-${NUMBER_OF_WARNINGS}}"
72+
ARMED_ARG="${WORKFLOW_INPUT_ARMED:-${ARMED}}"
73+
74+
echo "🔧 Using HEARTBEAT_INTERVAL=$HEARTBEAT_INTERVAL_ARG"
75+
echo "⚠️ Using NUMBER_OF_WARNINGS=$NUMBER_OF_WARNINGS_ARG"
76+
echo "🛡️ Armed: $ARMED_ARG"
77+
78+
# Build command arguments
79+
ARGS="$HEARTBEAT_INTERVAL_ARG $NUMBER_OF_WARNINGS_ARG"
80+
81+
if [ "$ARMED_ARG" = "true" ]; then
82+
ARGS="$ARGS --armed"
83+
fi
84+
85+
# Add --manual-dispatch if triggered manually
86+
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
87+
ARGS="$ARGS --manual-dispatch"
88+
echo "🔄 Manual dispatch detected - adding --manual-dispatch flag"
89+
fi
90+
91+
echo "🚀 Running: python3 dead_mans_switch.py $ARGS"
92+
python3 dead_mans_switch.py $ARGS

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Environments
2+
.env
3+
.venv
4+
env/
5+
venv/
6+
ENV/
7+
env.bak/
8+
venv.bak/
9+
10+
# Byte-compiled / optimized / DLL files
11+
__pycache__/
12+
*.py[cod]
13+
*$py.class
14+
15+
# MacOS
16+
**/.DS_Store
17+
18+
# VSCode
19+
.vscode/
20+
21+
# Jekyll and Ruby build files
22+
_site/
23+
.bundle/
24+
vendor/
25+
Gemfile.lock
26+
.sass-cache/
27+
.jekyll-cache/
28+
.jekyll-metadata

0 commit comments

Comments
 (0)