Compare commits
No commits in common. "v1.0" and "master" have entirely different histories.
|
|
@ -11,6 +11,8 @@ on:
|
||||||
MAVEN_SECRET:
|
MAVEN_SECRET:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
|
|
@ -40,4 +42,4 @@ jobs:
|
||||||
}]
|
}]
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn clean install
|
run: mvn clean install
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
NAME:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
MAVEN_USER:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
SERVER_HOST:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
SERVER_USER:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
DEPLOY_PATH:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
secrets:
|
|
||||||
MAVEN_SECRET:
|
|
||||||
required: true
|
|
||||||
SERVER_KEY:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Deploy Docker
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up JDK
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Install Maven
|
|
||||||
run: sudo apt update && sudo apt-get install maven -y
|
|
||||||
|
|
||||||
- name: Prepare Maven credentials
|
|
||||||
uses: s4u/maven-settings-action@v2.6.0
|
|
||||||
with:
|
|
||||||
servers: |
|
|
||||||
[{
|
|
||||||
"id": "repo",
|
|
||||||
"username": "${{ vars.MAVEN_NAME }}",
|
|
||||||
"password": "${{ secrets.MAVEN_SECRET }}"
|
|
||||||
}]
|
|
||||||
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn clean install
|
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
run: |
|
|
||||||
docker build -t ${{ inputs.NAME }} .
|
|
||||||
|
|
||||||
- name: Save Docker image as tar
|
|
||||||
run: |
|
|
||||||
docker save -o ${{ inputs.NAME }}.tar ${{ inputs.NAME }}
|
|
||||||
chmod 664 ${{ inputs.NAME }}.tar
|
|
||||||
|
|
||||||
- name: Transfer Docker image to server
|
|
||||||
uses: appleboy/scp-action@master
|
|
||||||
env:
|
|
||||||
NAME: ${{ inputs.NAME }}
|
|
||||||
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
|
|
||||||
with:
|
|
||||||
host: ${{ vars.SERVER_HOST }}
|
|
||||||
username: ${{ vars.SERVER_USER }}
|
|
||||||
key: ${{ secrets.SERVER_KEY }}
|
|
||||||
source: ${{ env.NAME }}.tar
|
|
||||||
target: ${{ env.DEPLOY_PATH }}
|
|
||||||
|
|
||||||
- name: SSH into server and load Docker image
|
|
||||||
uses: appleboy/ssh-action@master
|
|
||||||
env:
|
|
||||||
NAME: ${{ inputs.NAME }}
|
|
||||||
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
|
|
||||||
with:
|
|
||||||
host: ${{ vars.SERVER_HOST }}
|
|
||||||
username: ${{ vars.SERVER_USER }}
|
|
||||||
key: ${{ secrets.SERVER_KEY }}
|
|
||||||
script: |
|
|
||||||
cd ${{ env.DEPLOY_PATH }}
|
|
||||||
docker load -i ${{ env.NAME }}.tar
|
|
||||||
docker-compose down
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
MAVEN_USER:
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
secrets:
|
|
||||||
MAVEN_SECRET:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up JDK
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Install Maven
|
|
||||||
run: sudo apt update && sudo apt-get install maven -y
|
|
||||||
|
|
||||||
- name: Prepare Maven credentials
|
|
||||||
uses: s4u/maven-settings-action@v2.6.0
|
|
||||||
with:
|
|
||||||
servers: |
|
|
||||||
[{
|
|
||||||
"id": "repo",
|
|
||||||
"username": "${{ vars.MAVEN_NAME }}",
|
|
||||||
"password": "${{ secrets.MAVEN_SECRET }}"
|
|
||||||
}]
|
|
||||||
|
|
||||||
- name: Deploy with Maven
|
|
||||||
run: mvn deploy
|
|
||||||
|
|
@ -11,10 +11,7 @@ on:
|
||||||
MAVEN_SECRET:
|
MAVEN_SECRET:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
permissions:
|
permissions: read-all
|
||||||
contents: read
|
|
||||||
actions: read
|
|
||||||
checks: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
@ -45,14 +42,4 @@ jobs:
|
||||||
}]
|
}]
|
||||||
|
|
||||||
- name: Run tests with Maven
|
- name: Run tests with Maven
|
||||||
run: mvn test #-Dmaven.test.failure.ignore=true
|
run: mvn test
|
||||||
|
|
||||||
#- name: Test Report
|
|
||||||
# uses: dorny/test-reporter@v1
|
|
||||||
# if: success() || failure()
|
|
||||||
# with:
|
|
||||||
# name: Tests
|
|
||||||
# path: "**/target/surefire-reports/TEST-*.xml"
|
|
||||||
# reporter: java-junit
|
|
||||||
# fail-on-empty: 'false'
|
|
||||||
# fail-on-error: 'false'
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue