Skip to content

Commit

Permalink
github actions setting v6
Browse files Browse the repository at this point in the history
  • Loading branch information
sngbmYu committed Aug 13, 2024
1 parent 0f31e2c commit 91f4413
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ jobs:
needs: build-and-push

steps:
- name: Get Public IP
id: ip
uses: haythem/[email protected]

- name: Allow SSH access from GitHub Actions
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

- name: Add SSH key
run: |
mkdir -p ~/.ssh
Expand All @@ -48,4 +60,12 @@ jobs:
docker stop ustock-frontend || true
docker rm ustock-frontend || true
docker run -dp 80:80 --network ustock-network --name ustock-frontend ${{ secrets.DOCKERHUB_USERNAME }}/ustock-frontend:${{ github.sha }}
EOF
EOF
- name: Revoke SSH access from GitHub Actions
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

0 comments on commit 91f4413

Please sign in to comment.