Skip to content

Commit e860b8a

Browse files
authored
chore: ec2 테스트 커넥션 스크립트
1 parent b2bca93 commit e860b8a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

.github/workflows/cicd.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
# - uses: actions/checkout@v4
12-
- name: Test step
13-
run : |
14-
echo "깃헙액션 테스트, 현재 시간은:"
15-
TZ=Asia/Seoul date
1612

13+
# 이 아래 애들은 deploy 스텝에서 적용해야될듯?
1714
- name: Get Gihub Actions VM IP
1815
id: ip
1916
uses: haythem/public-ip@v1.3
@@ -36,6 +33,28 @@ jobs:
3633
--protocol tcp \
3734
--port 22 \
3835
--cidr ${{ steps.ip.outputs.ipv4 }}/32
36+
37+
- name: Test EC2 Connection And Manipulation
38+
uses: appleboy/ssh-action@master
39+
with:
40+
username: ubuntu
41+
host: ${{ secrets.EC2_ELASTIC_IP }}
42+
key: ${{ secrets.EC2_SSH_KEY }}
43+
script_stop: true
44+
script: |
45+
echo "[✔] GitHub Actions Connection Success" | tee -a ~/cicd-log.txt
46+
echo "Time: $(date '+%Y-%m-%d %H:%M:%S')" | tee -a ~/cicd-log.txt
47+
echo "Branch: ${{ github.ref_name }}" | tee -a ~/cicd-log.txt
48+
echo "Commit: ${{ github.sha }}" | tee -a ~/cicd-log.txt
49+
echo "-------------------------------" | tee -a ~/cicd-log.txt
50+
51+
- name: Remove GitHub Actions IP
52+
run: |
53+
aws ec2 revoke-security-group-ingress \
54+
--group-id ${{ secrets.AWS_SECURITY_GROUP_ID }} \
55+
--protocol tcp \
56+
--port 22 \
57+
--cidr ${{ steps.ip.outputs.ipv4 }}/32
3958
4059
# uses: actions/setup-java@v4
4160
# with:

0 commit comments

Comments
 (0)