Merge pull request 'push image to harbor' (#6) from feature/git-action3 into master
Reviewed-on: #6 Reviewed-by: saydev <gomdobi@sayinfo.co.kr>
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
name: Master-Build
|
||||
name: Main-Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
branches: ["main"]
|
||||
|
||||
jobs:
|
||||
build-war:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 8
|
||||
@@ -18,34 +18,21 @@ jobs:
|
||||
distribution: temurin
|
||||
java-version: "8"
|
||||
|
||||
- name: Cache Maven repo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: m2-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
m2-${{ runner.os }}-
|
||||
- name: Maven Build WAR
|
||||
run: mvn -B clean package -DskipTests
|
||||
|
||||
- name: Configure Maven Settings for Nexus
|
||||
- name: Docker login to Harbor
|
||||
run: |
|
||||
mkdir -p ~/.m2
|
||||
cat > ~/.m2/settings.xml <<EOF
|
||||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>nexus</id>
|
||||
<username>${{ secrets.NEXUS_USERNAME }}</username>
|
||||
<password>${{ secrets.NEXUS_PASSWORD }}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
EOF
|
||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login harbor.sayinfo.co.kr -u ${{ secrets.HARBOR_USERNAME }} --password-stdin
|
||||
|
||||
- name: Maven deploy (WAR to Nexus)
|
||||
run: mvn -B clean deploy -DskipTests
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t sayit-helpdesk:latest .
|
||||
|
||||
- name: Upload WAR artifact (optional)
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: sayit-helpdesk-war
|
||||
path: target/sayit.helpdesk.war
|
||||
- name: Tag image for Harbor
|
||||
run: |
|
||||
docker tag sayit-helpdesk:latest harbor.sayinfo.co.kr/helpdesk/helpdesk-service:latest
|
||||
|
||||
- name: Push image to Harbor
|
||||
run: |
|
||||
docker push harbor.sayinfo.co.kr/helpdesk/helpdesk-service:latest
|
||||
|
||||
Reference in New Issue
Block a user