Skip to content

Commit ea30f31

Browse files
committed
cd
1 parent 1a8f51c commit ea30f31

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.github/workflows/docker-image.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ on:
77
branches: [ "main" ]
88

99
jobs:
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

src/main/java/com/dockerforjavadevelopers/hello/HelloController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class HelloController {
99

1010
@RequestMapping("/")
1111
public String index() {
12-
return "Hello World\n";
12+
return "Hello java\n";
1313
}
1414

1515
}

0 commit comments

Comments
 (0)