mirror of
https://github.com/empayre/java-workflow.git
synced 2024-11-06 10:55:18 +00:00
190 lines
5.0 KiB
YAML
190 lines
5.0 KiB
YAML
name: Deploy Artifact
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
node-version:
|
|
description: 'Node version'
|
|
required: false
|
|
default: "16"
|
|
type: string
|
|
jdk-version:
|
|
description: 'Java version'
|
|
required: false
|
|
default: "17"
|
|
type: string
|
|
jdk-distribution:
|
|
description: 'Java distribution'
|
|
required: false
|
|
default: "temurin"
|
|
type: string
|
|
run-script-name:
|
|
description: ''
|
|
required: true
|
|
default: "build"
|
|
type: string
|
|
secrets:
|
|
github-token:
|
|
required: true
|
|
mm-webhook-url:
|
|
required: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --ignore-scripts
|
|
|
|
- name: Bundle specification
|
|
run: npm run ${{ inputs.run-script-name }}
|
|
|
|
- name: Validate specification
|
|
run: npm run validate
|
|
|
|
- name: Cache build
|
|
id: cache-build
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
web_deploy
|
|
key: ${{ runner.os }}-web-${{ github.sha }}
|
|
|
|
deploy-server:
|
|
runs-on: ubuntu-20.04
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup Maven
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: ${{ inputs.jdk-version }}
|
|
distribution: ${{ inputs.jdk-distribution }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --ignore-scripts
|
|
|
|
- name: Bundle specification
|
|
run: npm run ${{ inputs.run-script-name }}
|
|
|
|
- name: Cache build
|
|
id: cache-build
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
web_deploy
|
|
key: ${{ runner.os }}-web-${{ github.sha }}
|
|
|
|
- name: Retrieve commit info
|
|
run: |
|
|
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
|
|
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
|
|
id: commit_info
|
|
|
|
- name: Set artifact version
|
|
run: |
|
|
mvn versions:set versions:commit -DnewVersion="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-server"
|
|
- name: Deploy server package
|
|
run: |
|
|
mvn --batch-mode deploy -P="server"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.github-token }}
|
|
|
|
deploy-client:
|
|
runs-on: ubuntu-20.04
|
|
needs: [ build ]
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup Maven
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: ${{ inputs.jdk-version }}
|
|
distribution: ${{ inputs.jdk-distribution }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --ignore-scripts
|
|
|
|
- name: Bundle specification
|
|
run: npm run ${{ inputs.run-script-name }}
|
|
|
|
- name: Cache build
|
|
id: cache-build
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
web_deploy
|
|
key: ${{ runner.os }}-web-${{ github.sha }}
|
|
|
|
- name: Retrieve commit info
|
|
run: |
|
|
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
|
|
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
|
|
id: commit_info
|
|
|
|
- name: Set artifact version
|
|
run: |
|
|
mvn versions:set versions:commit -DnewVersion="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-client"
|
|
- name: Deploy client package
|
|
run: |
|
|
mvn --batch-mode deploy -P="client"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
success-notify:
|
|
runs-on: ubuntu-20.04
|
|
needs: [deploy-server, deploy-client]
|
|
if: success()
|
|
steps:
|
|
- name: Mattermost Notification
|
|
uses: rtCamp/action-slack-notify@v2.2.0
|
|
env:
|
|
SLACK_USERNAME: ${{ github.event.repository.name }}
|
|
SLACK_WEBHOOK: ${{ secrets.mm-webhook-url }}
|
|
SLACK_COLOR: "#00c100"
|
|
SLACK_LINK_NAMES: true
|
|
SLACK_FOOTER: ""
|
|
|
|
fail-notify:
|
|
runs-on: ubuntu-20.04
|
|
needs: [deploy-server, deploy-client]
|
|
if: failure()
|
|
steps:
|
|
- name: Mattermost Notification
|
|
uses: rtCamp/action-slack-notify@v2.2.0
|
|
env:
|
|
SLACK_USERNAME: ${{ github.event.repository.name }}
|
|
SLACK_WEBHOOK: ${{ secrets.mm-webhook-url }}
|
|
SLACK_COLOR: "#e40303"
|
|
SLACK_LINK_NAMES: true
|
|
SLACK_FOOTER: "" |