diff --git a/.github/workflows/prod-cd.yml b/.github/workflows/prod-cd.yml index 63552227..8128e0c3 100644 --- a/.github/workflows/prod-cd.yml +++ b/.github/workflows/prod-cd.yml @@ -6,7 +6,7 @@ on: branches: [ "prod" ] jobs: - ip-setup: + deploy: runs-on: ubuntu-latest steps: - name: Github Actions 호스트 IP 가져오기 @@ -28,33 +28,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - - name: IP를 파일로 저장 - run: echo "${{ steps.ip.outputs.ipv4 }}" > ip_address.txt - - - name: IP 주소를 아티팩트로 업로드 - uses: actions/upload-artifact@v3 - with: - name: ip-address - path: ip_address.txt - - deploy: - needs: [ ip-setup ] - runs-on: ubuntu-latest - steps: - - name: deploy job의 IP 확인하기 - uses: haythem/public-ip@bdddd92c198b0955f0b494a8ebeac529754262ff - - - name: 아티팩트에서 IP 주소 읽어 저장하기 - uses: actions/download-artifact@v3 - with: - name: ip-address - path: . - - - name: IP 주소 읽기 - run: | - IP_ADDRESS=$(cat ip_address.txt) - echo "IP_ADDRESS=${IP_ADDRESS}" >> $GITHUB_ENV - - name: 저장소 Checkout uses: actions/checkout@v4 @@ -114,7 +87,7 @@ jobs: - name: IP 제거 if: ${{ always() }} run: | - aws ec2 revoke-security-group-ingress --group-id "${{ secrets.AWS_SECURITY_GROUP_ID }}" --protocol "tcp" --port "${{ secrets.PROD_EC2_PORT }}" --cidr "${{ env.IP_ADDRESS }}/32" + aws ec2 revoke-security-group-ingress --group-id "${{ secrets.AWS_SECURITY_GROUP_ID }}" --protocol "tcp" --port "${{ secrets.PROD_EC2_PORT }}" --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 }}