-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (88 loc) · 4.01 KB
/
elk-deploy-workflow.yml
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
#name: Bottles ELK Deploy Workflow
#
#on:
# push:
# branches:
# - develop
#
#jobs:
# deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Setup JDK 17
# uses: actions/setup-java@v3
# with:
# distribution: 'corretto'
# java-version: '17'
#
# - name: Cache Gradle
# uses: actions/cache@v3
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
#
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
# shell: bash
#
# - name: Build with gradle
# run: ./gradlew clean build
# shell: bash
#
# - name: Get Github Actions IP
# id: ip
# uses: haythem/public-ip@v1.2
#
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ap-northeast-2
#
# - name: Add Github Actions IP to Security group
# run: |
# aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
#
# - name: Transfer file using SCP
# env:
# SERVER_HOST: ${{ secrets.ELK_SERVER_HOST }}
# SERVER_USER_NAME: ${{ secrets.ELK_SERVER_USER_NAME }}
# SERVER_PRIVATE_KEY: ${{ secrets.ELK_SERVER_PRIVATE_KEY }}
# run: |
# printf "%s" "$SERVER_PRIVATE_KEY" > private_key.pem
# chmod 600 private_key.pem
# scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -i private_key.pem ./elk/docker-compose.yml $SERVER_USER_NAME@$SERVER_HOST:/home/$SERVER_USER_NAME/docker
# scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -i private_key.pem ./elk/kibana/kibana.yml $SERVER_USER_NAME@$SERVER_HOST:/home/$SERVER_USER_NAME/elk/kibana
# scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -i private_key.pem ./elk/logstash/pipeline/logstash.conf $SERVER_USER_NAME@$SERVER_HOST:/home/$SERVER_USER_NAME/elk/logstash
# scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -i private_key.pem ./elk/logstash/logstash.yml $SERVER_USER_NAME@$SERVER_HOST:/home/$SERVER_USER_NAME/elk/logstash
# rm private_key.pem
#
# - name: Deploy to server
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.ELK_SERVER_HOST }}
# username: ${{ secrets.ELK_SERVER_USER_NAME }}
# key: ${{ secrets.ELK_SERVER_PRIVATE_KEY }}
# script: |
# if [ -f /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh ]; then
# rm /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh
# fi
#
# echo "export ELASTIC_USERNAME=${{ secrets.ELASTIC_USERNAME }}" > /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh
# echo "export ELASTIC_PASSWORD=${{ secrets.ELASTIC_PASSWORD }}" >> /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh
# echo "export LOGSTASH_PORT=${{ secrets.LOGSTASH_PORT }}" >> /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh
# echo "export KIBANA_PORT=${{ secrets.KIBANA_PORT }}" >> /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh
#
# sed 's/^export //' /home/${{ secrets.ELK_SERVER_USER_NAME }}/deploy/env_vars.sh > /home/${{ secrets.ELK_SERVER_USER_NAME }}/docker/.env
#
# - name: Remove Github Actions IP From Security Group
# run: |
# aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32