Skip to content

Commit

Permalink
feat: Add github action ip on security group
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz committed Jul 7, 2024
1 parent b21f6be commit f2d8694
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/showpot-dev-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,23 @@ jobs:
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/showpot:dev .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/showpot:dev
- name: Get Github Actions IP
id: ip
uses: haythem/[email protected]

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_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_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.3
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_DEV_HOST }}
username: ec2-user
Expand All @@ -59,3 +74,7 @@ jobs:
docker stop showpot-dev
docker rm showpot-dev
docker run -d -p 8080:8080 --name showpot-dev ${{ secrets.DOCKERHUB_USERNAME }}/showpot:dev
- name: Remove Github Actions IP From Security Group
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_DEV_SECURITY_GROUP_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32

0 comments on commit f2d8694

Please sign in to comment.