From a3ca95a7f2b5b8f4575f01ecc6347a62cef0d51b Mon Sep 17 00:00:00 2001
From: vharseko <vharseko@3a-systems.ru>
Date: Fri, 03 Sep 2021 16:35:49 +0000
Subject: [PATCH] actions: separate deploy (#182)

---
 /dev/null                    |   68 ----------------------
 .github/workflows/deploy.yml |   48 ++++++++++++++++
 .github/workflows/build.yml  |   33 +++++++++++
 README.md                    |    3 
 4 files changed, 83 insertions(+), 69 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..05bbd0b
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,33 @@
+name: Build Maven
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+    name: Maven build
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        java: [ '8', '11']
+        os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
+    steps:
+    - uses: actions/checkout@v2
+    - name: Java ${{ matrix.Java }} (${{ matrix.os }})
+      uses: actions/setup-java@v2
+      with:
+        java-version: ${{ matrix.java }}
+        distribution: 'adopt'
+    - name: Cache Maven packages
+      uses: actions/cache@v2
+      with:
+         path: ~/.m2/repository
+         key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
+         restore-keys: ${{ runner.os }}-m2-repository
+    - name: Build with Maven
+      env:
+        MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
+      run: mvn --batch-mode  --update-snapshots package --file pom.xml
\ No newline at end of file
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..83841e3
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,48 @@
+name: Deploy Maven
+
+on:
+  workflow_run:
+    push:
+       branches: [ master ]
+    workflows: ["Build Maven"]
+    types: [completed]
+  workflow_dispatch:
+jobs:
+  deploy:
+    name: Maven deploy
+    if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == '' }}
+    runs-on: 'ubuntu-latest'
+    steps:
+      - name: Print github context
+        env:
+          GITHUB_CONTEXT: ${{ toJSON(github) }}
+        run: echo "$GITHUB_CONTEXT"
+      - name: Install gpg secret key
+        env:
+           GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+        if: ${{ env.GPG_PRIVATE_KEY!=''}}
+        run: |
+           cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
+           gpg --list-secret-keys --keyid-format LONG
+      - uses: actions/checkout@v2
+      - name: Set up Java for publishing to Maven Central Repository OSS
+        uses: actions/setup-java@v2
+        with:
+          java-version: '8'
+          distribution: 'adopt'
+          server-id: ossrh
+          server-username: MAVEN_USERNAME
+          server-password: MAVEN_PASSWORD
+      - name: Cache Maven packages
+        uses: actions/cache@v2
+        with:
+         path: ~/.m2/repository
+         key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
+         restore-keys: ${{ runner.os }}-m2-repository
+      - name: Publish to the Maven Central Repository
+        env:
+          MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
+          MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
+          MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
+        if: ${{ env.MAVEN_USERNAME!='' && env.MAVEN_PASSWORD!=''}}
+        run: mvn --batch-mode --update-snapshots -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy --file pom.xml
\ No newline at end of file
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index f5bb21d..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-name: Build with Maven
-
-on:
-  push:
-    branches: [ master ]
-  pull_request:
-    branches: [ master ]
-
-jobs:
-  build:
-    name: Maven build
-    runs-on: ${{ matrix.os }}
-    strategy:
-      matrix:
-        java: [ '8', '11']
-        os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
-    steps:
-    - uses: actions/checkout@v2
-    - name: Java ${{ matrix.Java }} (${{ matrix.os }})
-      uses: actions/setup-java@v2
-      with:
-        java-version: ${{ matrix.java }}
-        distribution: 'adopt'
-    - name: Cache Maven packages
-      uses: actions/cache@v2
-      with:
-         path: ~/.m2/repository
-         key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
-         restore-keys: ${{ runner.os }}-m2-repository
-    - name: Build with Maven
-      env:
-        MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
-      run: mvn --batch-mode  --update-snapshots package --file pom.xml
-  deploy:
-    name: Maven deploy
-    needs: build
-    if: ${{ github.event_name=='push' && github.ref=='refs/heads/master'}}
-    runs-on: 'ubuntu-latest'
-    steps:
-      - name: Install gpg secret key
-        env:
-           GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
-        if: ${{ env.GPG_PRIVATE_KEY!=''}}
-        run: |
-           cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
-           gpg --list-secret-keys --keyid-format LONG
-      - uses: actions/checkout@v2
-      - name: Set up Java for publishing to Maven Central Repository OSS
-        uses: actions/setup-java@v2
-        with:
-          java-version: '8'
-          distribution: 'adopt'
-          server-id: ossrh
-          server-username: MAVEN_USERNAME
-          server-password: MAVEN_PASSWORD
-      - name: Cache Maven packages
-        uses: actions/cache@v2
-        with:
-         path: ~/.m2/repository
-         key: ${{ runner.os }}-m2-repository-${{ hashFiles('**/pom.xml') }}
-         restore-keys: ${{ runner.os }}-m2-repository
-      - name: Publish to the Maven Central Repository
-        env:
-          MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
-          MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
-          MAVEN_OPTS: -Dhttps.protocols=TLSv1.2 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.retryHandler.count=10
-        if: ${{ env.MAVEN_USERNAME!='' && env.MAVEN_PASSWORD!=''}}
-        run: mvn --batch-mode --update-snapshots -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy --file pom.xml
\ No newline at end of file
diff --git a/README.md b/README.md
index f5d3521..e24a56b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
 # <img alt="OpenDJ Logo" src="https://github.com/OpenIdentityPlatform/OpenDJ/raw/master/logo.png" width="300"/>
 [![Latest release](https://img.shields.io/github/release/OpenIdentityPlatform/OpenDJ.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/releases)
-[![Build](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/maven.yml/badge.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/maven.yml)
+[![Build](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/build.yml/badge.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/build.yml)
+[![Deploy](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/deploy.yml/badge.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/actions/workflows/deploy.yml)
 [![Issues](https://img.shields.io/github/issues/OpenIdentityPlatform/OpenDJ.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/issues)
 [![Last commit](https://img.shields.io/github/last-commit/OpenIdentityPlatform/OpenDJ.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/commits/master)
 [![License](https://img.shields.io/badge/license-CDDL-blue.svg)](https://github.com/OpenIdentityPlatform/OpenDJ/blob/master/LICENSE.md)

--
Gitblit v1.10.0