1111 workflow_dispatch :
1212
1313jobs :
14- k6 -test :
14+ load -test :
1515 runs-on : ubuntu-latest
16- # Only run if the VM Deploy workflow succeeded
17- if : ${{ github.event.workflow_run.conclusion == 'success' }}
1816
1917 steps :
20- - name : Checkout code
21- uses : actions/checkout@v4
18+ - name : Checkout code
19+ uses : actions/checkout@v4
2220
23- - name : Setup k6
24- uses : grafana/k6-action@v0.3.1
25- with :
26- filename : my-test.js
27-
28- - name : Run k6 performance test
29- run : |
30- echo "Running k6 tests after successful VM deployment..."
31- k6 run my-test.js --out json=k6-results.json
32-
33- - name : Upload k6 results
34- uses : actions/upload-artifact@v4
35- if : always()
36- with :
37- name : k6-performance-results
38- path : k6-results.json
21+ - name : Copy test file to server
22+ uses : appleboy/scp-action@v0.1.7
23+ with :
24+ host : ${{ secrets.SERVER_IP }}
25+ username : ${{ secrets.SERVER_ADMIN }}
26+ password : ${{ secrets.ADMIN_PASSWORD }}
27+ source : " my-test.js"
28+ target : " /tmp/"
29+
30+ - name : Run K6 test on server
31+ uses : appleboy/ssh-action@v1.2.1
32+ with :
33+ host : ${{ secrets.SERVER_IP }}
34+ username : ${{ secrets.SERVER_ADMIN }}
35+ password : ${{ secrets.ADMIN_PASSWORD }}
36+ script : |
37+ # Install k6 if not already installed
38+ if ! command -v k6 &> /dev/null; then
39+ sudo gpg -k
40+ sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
41+ echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
42+ sudo apt-get update
43+ sudo apt-get install -y k6
44+ fi
45+
46+ # Run test (use localhost since we're on the server)
47+ cd /tmp
48+ k6 run my-test.js --out json=results.json
49+
50+ - name : Download results
51+ uses : appleboy/scp-action@v0.1.7
52+ with :
53+ host : ${{ secrets.SERVER_IP }}
54+ username : ${{ secrets.SERVER_ADMIN }}
55+ password : ${{ secrets.ADMIN_PASSWORD }}
56+ source : " /tmp/results.json"
57+ target : " ."
58+ download : true
59+
60+ - name : Upload results
61+ if : always()
62+ uses : actions/upload-artifact@v4
63+ with :
64+ name : k6-results
65+ path : results.json
0 commit comments