mirror of
https://github.com/valitydev/java-workflow.git
synced 2024-11-06 01:25:18 +00:00
196 lines
6.0 KiB
YAML
196 lines
6.0 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@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- 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 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@v2
|
|
|
|
- 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.13
|
|
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@v2
|
|
|
|
- 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.13
|
|
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"'
|
|
|
|
publish-redoc:
|
|
runs-on: ubuntu-20.04
|
|
needs: [build]
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v2
|
|
|
|
- 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: Build static HTML (main way)
|
|
id: redoc_openapi
|
|
continue-on-error: true
|
|
run: >
|
|
npm run redoc ||
|
|
$(npm bin)/redoc-cli bundle openapi/openapi.yaml -o dist/index.html
|
|
|
|
- name: Build static HTML (alternative way) - Download specification bundle
|
|
if: ${{ steps.redoc_openapi.outcome == 'failure' }}
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: spec-bundle
|
|
path: ${{ inputs.dist-directory }}
|
|
|
|
- name: Build static HTML (alternative way) - Launch redoc-cli
|
|
if: ${{ steps.redoc_openapi.outcome == 'failure' }}
|
|
run: >
|
|
npm run redoc ||
|
|
$(npm bin)/redoc-cli bundle web_deploy/swagger.yaml -o dist/index.html
|
|
|
|
- name: Publish ReDoc on Github Pages
|
|
uses: peaceiris/actions-gh-pages@v3
|
|
with:
|
|
github_token: ${{ secrets.github-token }}
|
|
publish_dir: ./dist
|
|
force_orphan: true
|
|
|
|
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: ""
|