77 branches : [ "main" ]
88
99jobs :
10- runs-on : ubuntu-latest
11-
1210 build :
1311 needs : analyze
14-
12+ runs-on : ubuntu-latest
1513 steps :
1614 - name : Checkout repository
1715 uses : actions/checkout@v4
1816 - name : Build the Docker image
19- run : docker build . --file Dockerfile --tag javafile:123
17+ run : docker build . --file Dockerfile --tag javafile:${{github.sha}}
2018 - name : Set up Docker Buildx
2119 uses : docker/setup-buildx-action@v3
2220
@@ -31,10 +29,10 @@ jobs:
3129 with :
3230 context : .
3331 push : true
34- tags : manojkumar8008/ javafile:1234
32+ tags : javafile:${{github.sha}}
3533 analyze :
3634 name : Analyze
37-
35+ runs-on : ubuntu-latest
3836 permissions :
3937 security-events : write # Required for CodeQL to upload results
4038 actions : read
@@ -60,16 +58,19 @@ jobs:
6058 - name : Perform CodeQL Analysis
6159 uses : github/codeql-action/analyze@v3
6260 deploy :
63- needs : ["build,analyze"]
61+ needs : build
62+ runs-on : ubuntu-latest
6463 steps :
6564 - name : Deploy Docker image on EC2
6665 uses : appleboy/ssh-action@v1.0.3
6766 with :
6867 host : ${{ vars.EC2_HOST }}
6968 username : ${{ vars.EC2_USER }}
7069 key : ${{ secrets.EC2_KEY }}
71- script : |
72- docker pull manojkumar8008/javafile:1234
73- docker run -d -p 80:8080 manojkumar8008/javafile:1234
70+ script : |
71+ sudo docker pull javafile:${{github.sha}}
72+ sudo docker stop hello-world || true
73+ sudo docker rm hello-world || true
74+ sudo docker run -d --name hello-world -p 80:8080 javafile:${{github.sha}}
7475
7576
0 commit comments