Skip to content

Commit eca5444

Browse files
committed
[feature/#366] GitHub Actions 배포 시 SSH IP 동적 허용 및 삭제 로직 추가
1 parent 2d11be0 commit eca5444

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/deploy-dev.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,32 @@ jobs:
2828
- name: Build with Gradle
2929
run: ./gradlew build -x test
3030

31+
- name: Get GitHub Actions IP
32+
id: ip
33+
uses: haythem/public-ip@v1.3
34+
35+
- name: Configure AWS credentials
36+
uses: aws-actions/configure-aws-credentials@v5.1.1
37+
with:
38+
aws-access-key-id: ${{ secrets.AWS_USER_ACCESS_KEY }}
39+
aws-secret-access-key: ${{ secrets.AWS_USER_SECRET_KEY }}
40+
aws-region: ap-northeast-2
41+
42+
- name: Add GitHub IP to Security Group
43+
run: |
44+
aws ec2 authorize-security-group-ingress \
45+
--group-id ${{ secrets.AWS_SECURITY_GROUP_ID }} \
46+
--protocol tcp \
47+
--port 22 \
48+
--cidr ${{ steps.ip.outputs.ipv4 }}/32
49+
3150
- name: copy file via ssh
3251
uses: appleboy/scp-action@master
3352
with:
3453
host: ${{ secrets.IBAS_DEV_HOST }}
3554
username: ${{ secrets.IBAS_DEV_USERNAME }}
3655
key: ${{ secrets.IBAS_DEV_SSH_KEY }}
3756
passphrase: ${{ secrets.IBAS_DEV_PASSWORD }}
38-
# port: ${{ secrets.PORT }} # default : 22
3957
source: "docker-compose.yml"
4058
target: ${{ secrets.IBAS_DEV_DEPLOY_PATH }}
4159

@@ -66,6 +84,14 @@ jobs:
6684
username: ${{ secrets.IBAS_DEV_USERNAME }}
6785
key: ${{ secrets.IBAS_DEV_SSH_KEY }}
6886
passphrase: ${{ secrets.IBAS_DEV_PASSWORD }}
69-
# port: ${{ secrets.PORT }} # default : 22
7087
script: |
7188
bash ${{ secrets.IBAS_DEV_DEPLOY_PATH }}/deploy.sh
89+
90+
- name: Remove GitHub IP from Security Group
91+
if: always()
92+
run: |
93+
aws ec2 revoke-security-group-ingress \
94+
--group-id ${{ secrets.AWS_SECURITY_GROUP_ID }} \
95+
--protocol tcp \
96+
--port 22 \
97+
--cidr ${{ steps.ip.outputs.ipv4 }}/32

0 commit comments

Comments
 (0)