java-workflow/.github/workflows/maven-swag-deploy.yml
2023-08-07 19:56:02 +07:00

157 lines
4.8 KiB
YAML

name: Deploy Artifact
on:
workflow_call:
inputs:
node-version:
description: Node version
required: false
default: "16"
type: string
dist-directory:
description: Directory where bundled artifacts are built
required: false
default: "web_deploy"
type: string
secrets:
server-username:
required: true
server-password:
required: true
deploy-secret-key:
required: true
deploy-secret-key-password:
required: true
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:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Bundle specification
run: npm run build
- name: Validate specification
run: npm run validate
- name: Upload specification bundle
uses: actions/upload-artifact@v3
with:
name: spec-bundle
path: ${{ inputs.dist-directory }}
if-no-files-found: error
retention-days: 7
deploy-server:
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download specification bundle
uses: actions/download-artifact@v3
with:
name: spec-bundle
path: ${{ inputs.dist-directory }}
- 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
uses: valitydev/action-deploy-jdk-package@v1.0.18
with:
server-username: ${{ secrets.server-username }}
server-password: ${{ secrets.server-password }}
deploy-secret-key: ${{ secrets.deploy-secret-key }}
deploy-secret-key-password: ${{ secrets.deploy-secret-key-password }}
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-server" -P="server"'
deploy-client:
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download specification bundle
uses: actions/download-artifact@v3
with:
name: spec-bundle
path: ${{ inputs.dist-directory }}
- 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 --batch-mode versions:set versions:commit -DnewVersion="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-client"
- name: Deploy client package
uses: valitydev/action-deploy-jdk-package@v1.0.18
with:
server-username: ${{ secrets.server-username }}
server-password: ${{ secrets.server-password }}
deploy-secret-key: ${{ secrets.deploy-secret-key }}
deploy-secret-key-password: ${{ secrets.deploy-secret-key-password }}
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}-client" -P="client"'
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: ""