|
1 | | -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven |
3 | | - |
4 | | -# This workflow uses actions that are not certified by GitHub. |
5 | | -# They are provided by a third-party and are governed by |
6 | | -# separate terms of service, privacy policy, and support |
7 | | -# documentation. |
8 | | - |
9 | | -name: Java CI with Maven |
10 | | - |
| 1 | +name: Maven Reusable Workflow |
| 2 | +run-name: GitHub Action Maven Reusable Workflow |
11 | 3 | on: |
12 | | - push: |
13 | | - branches: [ "master" ] |
14 | | - pull_request: |
15 | | - branches: [ "master" ] |
| 4 | + workflow_dispatch: |
| 5 | + workflow_call: |
16 | 6 |
|
17 | 7 | jobs: |
18 | | - build: |
19 | | - |
| 8 | + Maven-Workflow: |
20 | 9 | runs-on: ubuntu-latest |
21 | | - |
22 | 10 | steps: |
23 | | - - uses: actions/checkout@v3 |
24 | | - - name: Set up JDK 17 |
25 | | - uses: actions/setup-java@v3 |
26 | | - with: |
| 11 | + - uses: actions/checkout@v3 |
| 12 | + - name: Set up JDK 17 |
| 13 | + uses: actions/setup-java@v3 |
| 14 | + with: |
27 | 15 | java-version: '17' |
28 | 16 | distribution: 'temurin' |
29 | 17 | cache: maven |
30 | | - - name: Build with Maven |
31 | | - run: mvn -B package --file pom.xml |
32 | | - |
33 | | - - uses: actions/upload-artifact@v4 |
34 | | - with: |
35 | | - name: buildArtifact |
36 | | - path: target/*.jar |
37 | | - |
38 | | - Deployment: |
39 | | - |
40 | | - runs-on: ubuntu-latest |
41 | | - needs: build |
42 | | - strategy: |
43 | | - matrix: |
44 | | - deployHosts: ${{ fromJson(vars.HOSTLIST) }} |
45 | | - steps: |
46 | | - - uses: actions/download-artifact@v4 |
47 | | - with: |
48 | | - name: buildArtifact |
49 | | - path: . |
50 | | - - name: Deploy Artifacts |
51 | | - run: ls -laRt |
52 | | - - name: copy file to server |
53 | | - |
54 | | - with: |
55 | | - host: ${{ matrix.deployHosts }} |
56 | | - username: ${{ secrets.USERNAME }} |
57 | | - password: ${{ secrets.PASS }} |
58 | | - port: 22 |
59 | | - source: '*.jar' |
60 | | - target: /tmp/ |
61 | | - - name: executing remote ssh commands using password |
62 | | - |
63 | | - with: |
64 | | - host: ${{ matrix.deployHosts }} |
65 | | - username: ${{ secrets.USERNAME }} |
66 | | - password: ${{ secrets.PASS }} |
67 | | - port: 22 |
68 | | - script: | |
69 | | - sudo cp /tmp/*.jar /opt/ |
70 | | - sudo ls -lart /opt |
| 18 | + - name: Build with Maven |
| 19 | + run: mvn -B package --file pom.xml |
0 commit comments