From dde781cc3fc7e0395e74b6cbc449eb97186802a7 Mon Sep 17 00:00:00 2001 From: "Goulven.Furet" Date: Tue, 2 Jan 2024 16:14:50 +0100 Subject: [PATCH] workflows --- .github/workflows/buildDeploy.yml | 46 -------- .github/workflows/publishInfraBeta.yml | 26 +++++ ...{publishInfra.yml => publishInfraProd.yml} | 6 +- .github/workflows/publishJarsBeta.yml | 26 +++++ .../{publishJars.yml => publishJarsProd.yml} | 10 +- .github/workflows/releaseDeployProd.yml | 104 ++++++++++++++++++ .github/workflows/testAndPublishBeta.yml | 75 +++++++++++++ 7 files changed, 239 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/buildDeploy.yml create mode 100644 .github/workflows/publishInfraBeta.yml rename .github/workflows/{publishInfra.yml => publishInfraProd.yml} (80%) create mode 100644 .github/workflows/publishJarsBeta.yml rename .github/workflows/{publishJars.yml => publishJarsProd.yml} (65%) create mode 100644 .github/workflows/releaseDeployProd.yml create mode 100644 .github/workflows/testAndPublishBeta.yml diff --git a/.github/workflows/buildDeploy.yml b/.github/workflows/buildDeploy.yml deleted file mode 100644 index 55bd77b23..000000000 --- a/.github/workflows/buildDeploy.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow will build and push a latest artefacts to the server - -on: push - -name: Build and deploy artefacts - -jobs: - deploy: - name: Deploy - runs-on: self-hosted - - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK 21 - uses: actions/setup-java@v2 - with: - java-version: '21' - distribution: 'adopt' - - - name: Build with Maven - run: mvn --batch-mode --update-snapshots install - - - name: Deploy API to server - uses: easingthemes/ssh-deploy@main - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - ARGS: "-rltgoDzvO --delete" - SOURCE: "/api/target/api-0.0.1-SNAPSHOT.jar" - REMOTE_HOST: ${{ secrets.REMOTE_HOST }} - REMOTE_USER: ${{ secrets.REMOTE_USER }} - TARGET: "/opt/open4goods/bin/latest/api-latest.jar" - - - name: Deploy UI to server - uses: easingthemes/ssh-deploy@main - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - ARGS: "-rltgoDzvO --delete" - SOURCE: "/ui/target/ui-0.0.1-SNAPSHOT.jar" - REMOTE_HOST: ${{ secrets.REMOTE_HOST }} - REMOTE_USER: ${{ secrets.REMOTE_USER }} - TARGET: "/opt/open4goods/bin/latest/ui-latest.jar" - - - - diff --git a/.github/workflows/publishInfraBeta.yml b/.github/workflows/publishInfraBeta.yml new file mode 100644 index 000000000..071ac114e --- /dev/null +++ b/.github/workflows/publishInfraBeta.yml @@ -0,0 +1,26 @@ +# This workflow will trigger the remote ssh script to restart infrastructure with the latest artefacts version +on: workflow_dispatch + +name: Publish latest infrastructure on qualification environment + +jobs: + deploy: + name: publish-infra-beta + runs-on: self-hosted + + steps: + - name: Publish via ssh + uses: appleboy/ssh-action@v1.0.2 + with: + host: ${{ secrets.REMOTE_BETA_HOST }} + username: ${{ secrets.REMOTE_BETA_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY}} + script: sh /opt/open4goods/bin/publish-infra.sh + + + + + + + + diff --git a/.github/workflows/publishInfra.yml b/.github/workflows/publishInfraProd.yml similarity index 80% rename from .github/workflows/publishInfra.yml rename to .github/workflows/publishInfraProd.yml index 3611ad299..2534a0b3d 100644 --- a/.github/workflows/publishInfra.yml +++ b/.github/workflows/publishInfraProd.yml @@ -2,16 +2,16 @@ # restart infrastructure with the latest artefacts version on: workflow_dispatch -name: Publish latest infrastructure +name: Publish latest infrastructure on production environment jobs: deploy: - name: publish-infra + name: publish-infra-prod runs-on: self-hosted steps: - name: Publish via ssh - uses: appleboy/ssh-action@v1.0.0 + uses: appleboy/ssh-action@v1.0.2 with: host: ${{ secrets.REMOTE_HOST }} username: ${{ secrets.REMOTE_USER }} diff --git a/.github/workflows/publishJarsBeta.yml b/.github/workflows/publishJarsBeta.yml new file mode 100644 index 000000000..7024d45d0 --- /dev/null +++ b/.github/workflows/publishJarsBeta.yml @@ -0,0 +1,26 @@ +# This workflow will trigger the remote ssh script to +# restart application with the latest artefacts version +on: workflow_dispatch + +name: Restart applications on qualification environment + +jobs: + deploy: + name: publish-jars-beta + runs-on: self-hosted + + steps: + - name: Publish via ssh + uses: appleboy/ssh-action@v1.0.2 + with: + host: ${{ secrets.REMOTE_BETA_HOST }} + username: ${{ secrets.REMOTE_BETA_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY}} + script: sh /opt/open4goods/bin/publish-jars.sh + + + + + + + diff --git a/.github/workflows/publishJars.yml b/.github/workflows/publishJarsProd.yml similarity index 65% rename from .github/workflows/publishJars.yml rename to .github/workflows/publishJarsProd.yml index 59f4b6cf8..af5678a3e 100644 --- a/.github/workflows/publishJars.yml +++ b/.github/workflows/publishJarsProd.yml @@ -2,19 +2,19 @@ # restart application with the latest artefacts version on: workflow_dispatch -name: Publish latest apps +name: Restart applications on production environment jobs: deploy: - name: publish-jars + name: publish-jars-prod runs-on: self-hosted steps: - name: Publish via ssh - uses: appleboy/ssh-action@v0.1.10 + uses: appleboy/ssh-action@v1.0.2 with: - host: ${{ secrets.REMOTE_HOST }} - username: ${{ secrets.REMOTE_USER }} + host: ${{ secrets.REMOTE_BETA_HOST }} + username: ${{ secrets.REMOTE_BETA_USER }} key: ${{ secrets.SSH_PRIVATE_KEY}} script: sh /opt/open4goods/bin/publish-jars.sh diff --git a/.github/workflows/releaseDeployProd.yml b/.github/workflows/releaseDeployProd.yml new file mode 100644 index 000000000..d6875496c --- /dev/null +++ b/.github/workflows/releaseDeployProd.yml @@ -0,0 +1,104 @@ +on: workflow_dispatch +name: release-deploy-prod + +jobs: + release: + runs-on: ubuntu-latest + steps: + + + - uses: actions/checkout@v4 + + ############################################ + # Install Java + ########################################### + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'adopt' + cache: maven + + + ############################################ + # Build jars + ########################################### + + - name: Build jars with Maven + run: mvn --batch-mode --update-snapshots install -Dmaven.test.skip=true + + ############################################ + # Build maven site + ########################################### + + - name: Build Maven site + run: mvn --batch-mode clean site site:stage scm-publish:publish-scm + + + ############################################ + # Build the changelogs + ########################################### + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + ############################################ + # Create the release + ########################################### + + - name: Create Release + uses: mikepenz/action-gh-release@v0.2.0-a03 #softprops/action-gh-release + with: + body: ${{steps.github_release.outputs.changelog}} + + + + ############################################ + # Deploy API to production server + ########################################### + + - name: Deploy API to server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-rltgoDzvO --delete" + SOURCE: "/api/target/api-0.0.1-SNAPSHOT.jar" + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: "/opt/open4goods/bin/latest/api-latest.jar" + + + ############################################ + # Deploy UI to production server + ########################################### + + - name: Deploy UI to production server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-rltgoDzvO --delete" + SOURCE: "/ui/target/ui-0.0.1-SNAPSHOT.jar" + REMOTE_HOST: ${{ secrets.REMOTE_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_USER }} + TARGET: "/opt/open4goods/bin/latest/ui-latest.jar" + + ############################################ + # Restart applications + ########################################### + + - name: Publish applications + uses: appleboy/ssh-action@v1.0.2 + with: + host: ${{ secrets.REMOTE_HOST }} + username: ${{ secrets.REMOTE_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY}} + script: sh /opt/open4goods/bin/publish-jars.sh + + + + + \ No newline at end of file diff --git a/.github/workflows/testAndPublishBeta.yml b/.github/workflows/testAndPublishBeta.yml new file mode 100644 index 000000000..98e36d7c1 --- /dev/null +++ b/.github/workflows/testAndPublishBeta.yml @@ -0,0 +1,75 @@ +# This workflow will build, test and push the latest version on the beta environment. + +on: push + +name: Build, Test and publish on beta.nudger.fr + +jobs: + deploy: + name: test-build-publish-beta + runs-on: self-hosted + + steps: + - uses: actions/checkout@v4 + + ############################################ + # Install Java + ########################################### + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'adopt' + cache: maven + + ############################################ + # Maven build and testing + ########################################### + + - name: Build and test with Maven + run: mvn --batch-mode --update-snapshots install + + ############################################ + # Deploy api JAR to qualification environment + ########################################### + + - name: Deploy API to qualification server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-rltgoDzvO --delete" + SOURCE: "/api/target/api-0.0.1-SNAPSHOT.jar" + REMOTE_HOST: ${{ secrets.REMOTE_BETA_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_BETA_USER }} + TARGET: "/opt/open4goods/bin/latest/api-latest.jar" + + ############################################ + # Deploy ui JAR to qualification environment + ########################################### + + - name: Deploy UI to qualification server + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + ARGS: "-rltgoDzvO --delete" + SOURCE: "/ui/target/ui-0.0.1-SNAPSHOT.jar" + REMOTE_HOST: ${{ secrets.REMOTE_BETA_HOST }} + REMOTE_USER: ${{ secrets.REMOTE_BETA_USER }} + TARGET: "/opt/open4goods/bin/latest/ui-latest.jar" + + ############################################ + # Restarting application + ########################################### + + - name: Publish applications + uses: appleboy/ssh-action@v1.0.2 + with: + host: ${{ secrets.REMOTE_BETA_HOST }} + username: ${{ secrets.REMOTE_BETA_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY}} + script: sh /opt/open4goods/bin/publish-jars.sh + + + + +