-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (83 loc) · 3 KB
/
example.yml
File metadata and controls
94 lines (83 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Example SSH Action Usage
on:
workflow_dispatch: # Allows manual triggering
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Execute deployment script
uses: ./
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: '22' # Optional, defaults to 22
script: |
echo "Deployment started at $(date)"
whoami
pwd
uptime
echo "Deployment completed!"
- name: Execute maintenance script on custom port
uses: ./
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: '2222'
script: |
#!/bin/bash
echo "Running system maintenance..."
df -h
free -m
echo "Maintenance completed!"
- name: Deploy with environment variables
uses: ./
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
envs: 'DEPLOY_ENV=staging,APP_VERSION=1.0.0,NODE_ENV=production'
script: |
#!/bin/bash
echo "=== Deployment with Environment Variables ==="
echo "Environment: $DEPLOY_ENV"
echo "App Version: $APP_VERSION"
echo "Node Environment: $NODE_ENV"
# Example usage of environment variables
if [ "$DEPLOY_ENV" = "production" ]; then
echo "🚀 Production deployment detected"
else
echo "🧪 Staging deployment detected"
fi
echo "Deployment completed!"
- name: Complex environment variables example
uses: ./
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
envs: |
DATABASE_URL=${{ secrets.DATABASE_URL }},
API_KEY=${{ secrets.API_KEY }},
DEBUG=true,
LOG_LEVEL=info,
MAX_CONNECTIONS=100
script: |
#!/bin/bash
echo "=== Complex Environment Variables Test ==="
echo "Database configured: $([ -n "$DATABASE_URL" ] && echo "✅ Yes" || echo "❌ No")"
echo "API Key configured: $([ -n "$API_KEY" ] && echo "✅ Yes" || echo "❌ No")"
echo "Debug mode: $DEBUG"
echo "Log level: $LOG_LEVEL"
echo "Max connections: $MAX_CONNECTIONS"
# Example of conditional logic based on environment variables
if [ "$DEBUG" = "true" ]; then
echo "🐛 Debug mode enabled - showing detailed information"
env | grep -E "(DATABASE_URL|API_KEY|DEBUG|LOG_LEVEL|MAX_CONNECTIONS)" | sed 's/=.*/=***/'
fi
echo "Environment variables test completed!"