Skip to content

Commit 87125cf

Browse files
committed
feature: GHA workflow
1 parent 7b1e358 commit 87125cf

File tree

2 files changed

+72
-11
lines changed

2 files changed

+72
-11
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
3+
name: WordPress Deployment
4+
5+
on:
6+
push:
7+
branches:
8+
- task_xxx # Replace with your branch name to test GitHub Actions without pushing to the dev branch
9+
- dev
10+
11+
jobs:
12+
deploy-wordpress:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup SOCKS5 Proxy
19+
env:
20+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
21+
BASTION_HOST: ${{ vars.BASTION_HOST }}
22+
K3S_SERVER_HOST: ${{ vars.K3S_SERVER_HOST }}
23+
BASTION_USER: ${{ vars.BASTION_USER }}
24+
EC2_USER: ${{ vars.EC2_USER }}
25+
run: |
26+
# Start SSH agent and add the SSH key
27+
eval "$(ssh-agent -s)"
28+
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
29+
ssh -D 1080 -N -q -o StrictHostKeyChecking=no "$BASTION_USER@$BASTION_HOST" &
30+
31+
- name: Deploy WordPress
32+
env:
33+
KUBECONFIG: /tmp/k3s.yml
34+
run: |
35+
echo "${{ vars.K3S_CONFIG }}" >> $KUBECONFIG
36+
chmod 600 "$KUBECONFIG"
37+
kubectl get namespace wordpress || kubectl create namespace wordpress
38+
helm upgrade --install wordpress -n wordpress helm-charts/wordpress

README.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ This repository contains all necessary resources and configurations to deploy an
3939

4040
### GitHub variables and GitHub Secrets variables
4141
3. **K3S token variable** ```K3S_TOKEN``` is stored in GitHub Secrets. It was created using the following command:
42-
```gh secret set K3S_TOKEN --body "<K3S_TOKEN>" --repo lexxnsk/rsschool-devops-course-tasks```
42+
```
43+
gh secret set SSH_PRIVATE_KEY --body "$(cat aws.pem)" --repo lexxnsk/rsschool-devops-course-tasks
44+
gh secret set K3S_TOKEN --body "<K3S_TOKEN>" --repo lexxnsk/rsschool-devops-course-tasks
45+
gh variable set BASTION_HOST --body "bastion.rss.myslivets.ru" --repo lexxnsk/rsschool-devops-course-tasks-application
46+
gh variable set K3S_SERVER_HOST --body "10.0.2.10" --repo lexxnsk/rsschool-devops-course-tasks-application
47+
gh variable set BASTION_USER --body "ubuntu" --repo lexxnsk/rsschool-devops-course-tasks-application
48+
gh variable set EC2_USER --body "ec2-user" --repo lexxnsk/rsschool-devops-course-tasks-application
49+
gh variable set K3S_CONFIG --body "$(cat /Users/amyslivets/Documents/AWS/k3s.yml)" --repo lexxnsk/rsschool-devops-course-tasks-application
50+
```
4351

4452
You can list variables and secrets using the following commands:
4553
```gh variable list --repo lexxnsk/rsschool-devops-course-tasks```
@@ -90,21 +98,36 @@ local-path (default) rancher.io/local-path Delete WaitForFir
9098
```
9199
- Here is a simple NGINX reverse proxy config to be installed on Bastion Host:
92100
```
93-
sudo vi /etc/nginx/conf.d/jenkins.conf
101+
sudo vi /etc/nginx/conf.d/nginx.conf
102+
103+
server {
104+
listen 80;
105+
server_name jenkins.rss.myslivets.ru;
94106
107+
location / {
108+
proxy_pass http://10.0.2.10:32000; # Forward requests to the Jenkins server
109+
proxy_http_version 1.1;
110+
proxy_set_header Upgrade $http_upgrade;
111+
proxy_set_header Connection 'upgrade';
112+
proxy_set_header Host $host;
113+
proxy_set_header X-Real-IP $remote_addr;
114+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115+
proxy_set_header X-Forwarded-Proto $scheme;
116+
}
117+
}
95118
server {
96119
listen 80;
97-
server_name jenkins.myslivets.ru;
120+
server_name wordpress.rss.myslivets.ru;
98121
99122
location / {
100-
proxy_pass http://10.0.2.10:32000; # Forward requests to Jenkins
101-
proxy_http_version 1.1; # Use HTTP/1.1 for proxying
102-
proxy_set_header Upgrade $http_upgrade; # Handle WebSocket connections
103-
proxy_set_header Connection 'upgrade'; # Handle WebSocket connections
104-
proxy_set_header Host $host; # Preserve original Host header
105-
proxy_set_header X-Real-IP $remote_addr; # Pass the client IP address
106-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Preserve client IP
107-
proxy_set_header X-Forwarded-Proto $scheme; # Preserve protocol (http or https)
123+
proxy_pass http://10.0.2.10:32001; # Forward requests to the WordPress server
124+
proxy_http_version 1.1;
125+
proxy_set_header Upgrade $http_upgrade;
126+
proxy_set_header Connection 'upgrade';
127+
proxy_set_header Host $host;
128+
proxy_set_header X-Real-IP $remote_addr;
129+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
130+
proxy_set_header X-Forwarded-Proto $scheme;
108131
}
109132
}
110133

0 commit comments

Comments
 (0)