Skip to content

Commit 5075096

Browse files
committed
Final changes for deployment
1 parent d428279 commit 5075096

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/main.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,38 @@ jobs:
5656
# be deployed to ECS.
5757
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
5858
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
59-
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
59+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
60+
61+
Continuous-Deployment:
62+
needs: build-and-push-ecr-image
63+
runs-on: self-hosted
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
68+
- name: Configure AWS credentials
69+
uses: aws-actions/configure-aws-credentials@v1
70+
with:
71+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
72+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
73+
aws-region: ${{ secrets.AWS_REGION }}
74+
75+
- name: Login to Amazon ECR
76+
id: login-ecr
77+
uses: aws-actions/amazon-ecr-login@v1
78+
79+
80+
- name: Pull latest images
81+
run: |
82+
docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
83+
84+
#- name: Stop and remove container if running
85+
# run: |
86+
# docker ps -q --filter "name=network_security" | grep -q . && docker stop networksecurity && docker rm -fv networksecurity
87+
88+
- name: Run Docker Image to serve users
89+
run: |
90+
docker run -d -p 8080:8080 --ipc="host" --name=network_security -e 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' -e 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' -e 'AWS_REGION=${{ secrets.AWS_REGION }}' ${{ secrets.AWS_ECR_LOGIN_URI }}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
91+
- name: Clean previous images and containers
92+
run: |
93+
docker system prune -f

0 commit comments

Comments
 (0)