From 5f90fae881c8affd94bd7840fd23ad322a0fff03 Mon Sep 17 00:00:00 2001 From: Bishal Thapaliya Date: Tue, 12 Mar 2024 11:34:49 +0100 Subject: [PATCH 1/4] ci(github): create reusable build and pr (#38) --- .github/workflows/_reusable_build.yml | 80 +++++++++++++++++++++++++++ .github/workflows/build_pr.yml | 9 +++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/_reusable_build.yml create mode 100644 .github/workflows/build_pr.yml diff --git a/.github/workflows/_reusable_build.yml b/.github/workflows/_reusable_build.yml new file mode 100644 index 0000000..f2384d5 --- /dev/null +++ b/.github/workflows/_reusable_build.yml @@ -0,0 +1,80 @@ +name: Resuable Build + +on: + workflow_call: + inputs: + ref: + type: string + default: ${{ github.ref }} + description: The branch ref to build. Leave empty to use workflow branch. + publish: + type: boolean + default: false + description: Publish artifacts to Maven repository + repository-id: + type: string + default: snapshots + description: Id of the Maven repository + repository-url: + type: string + default: ${{ vars.SNAPSHOTS_REPOSITORY_URL }} + description: URL of the Maven repository + upload-bos-file: + type: boolean + default: false + description: To upload the BOS file as a Github Artifact + + secrets: + BONITA_CI_PAT: + required: true + +permissions: + contents: read + checks: write + pull-requests: write + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: bonitasoft/bonita-application-directory + token: ${{ secrets.BONITA_CI_PAT }} + ref: ${{ inputs.ref }} + + - name: ☕ Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 11 + cache: maven + + - name: Configure Maven Settings + uses: bonitasoft/maven-settings-action@v1 + with: + keeper-secret-config: ${{ secrets.KSM_CONFIG }} + + - name: Maven Build + timeout-minutes: 90 + run: ./mvnw -ntp clean verify + + - name: Get deploy file + if: ${{ inputs.publish }} + id: deploy-file + run: | + FILE_NAME=$(./mvnw help:evaluate -Dexpression=project.build.finalName -DforceStdout -q) + echo "DEPLOY_FILE=target/${FILE_NAME}.zip" >> "$GITHUB_OUTPUT" + + - name: Maven Deploy + if: ${{ inputs.publish }} + run: ./mvnw deploy:deploy-file -Dfile=${{ steps.deploy-file.outputs.DEPLOY_FILE }} -DrepositoryId=${{ inputs.repository-id }} -Durl=${{ inputs.repository-url }} + + - name: Upload .bos file + if: ${{ inputs.upload-bos-file }} + uses: actions/upload-artifact@v4 + with: + name: bonita-application-directory + path: "**/target/bonita-application-directory-*.bos" + retention-days: 10 diff --git a/.github/workflows/build_pr.yml b/.github/workflows/build_pr.yml new file mode 100644 index 0000000..2469731 --- /dev/null +++ b/.github/workflows/build_pr.yml @@ -0,0 +1,9 @@ +name: Build Pull Request + +on: + pull_request: + +jobs: + build-pr: + uses: ./.github/workflows/_reusable_build.yml + secrets: inherit From 4dc9b00393ca3870bb5fe48ad1cca465ae7d0ec2 Mon Sep 17 00:00:00 2001 From: Adrien Kantcheff <5028967+akantcheff@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:22:16 +0100 Subject: [PATCH 2/4] ci(build): create build workflow for base branches (#39) * ci(build): create build workflow for base branches * ci(jenkins): remove Jenkinsfile --- .github/workflows/build.yml | 21 +++++++++++++++++++++ .github/workflows/build_pr.yml | 5 +++++ Jenkinsfile | 29 ----------------------------- 3 files changed, 26 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 Jenkinsfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f7c8e6e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Build + +on: + push: + branches: + - "[0-9]+.[0-9]+.x" + - "master" + - "release-*" + - "dev" + paths-ignore: + - ".github/**" + - "**/README.md" + - "!.github/workflows/build.yml" + - "!.github/workflows/_reusable_build.yml" + +jobs: + build: + uses: ./.github/workflows/_reusable_build.yml + with: + publish: true + secrets: inherit diff --git a/.github/workflows/build_pr.yml b/.github/workflows/build_pr.yml index 2469731..70d06d7 100644 --- a/.github/workflows/build_pr.yml +++ b/.github/workflows/build_pr.yml @@ -2,6 +2,11 @@ name: Build Pull Request on: pull_request: + paths-ignore: + - ".github/**" + - "**/README.md" + - "!.github/workflows/build_pr.yml" + - "!.github/workflows/_reusable_build.yml" jobs: build-pr: diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 35796a0..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,29 +0,0 @@ - -properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5']]]) - -timestamps { - ansiColor('xterm') { - node { - stage('Setup') { - checkout scm - } - - stage('Build') { - try { - def currentBranch = env.BRANCH_NAME - def isBaseBranch = currentBranch == 'master' || currentBranch == 'dev' || currentBranch?.startsWith('release-') || currentBranch?.matches('7\\..+\\.x') - configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { - if(!isBaseBranch){ - sh "./mvnw -s ${MAVEN_SETTINGS} --no-transfer-progress -B clean verify -Djvm=${env.JAVA_HOME_11}/bin/java" - }else{ - sh "./mvnw -s ${MAVEN_SETTINGS} --no-transfer-progress -B clean deploy -Djvm=${env.JAVA_HOME_11}/bin/java -DaltDeploymentRepository=${env.ALT_DEPLOYMENT_REPOSITORY_SNAPSHOTS}" - } - } - archiveArtifacts '**/target/bonita-application-directory-*.bos' - } finally { - junit allowEmptyResults : true, testResults: '**/target/surefire-reports/*.xml' - } - } - } - } -} From 58e11016ee80c112a7de8b38d368208c8bcf743b Mon Sep 17 00:00:00 2001 From: Adrien Kantcheff <5028967+akantcheff@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:31:44 +0100 Subject: [PATCH 3/4] ci(github): add all checks pass workflow (#41) --- .github/workflows/all_check_passed.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/all_check_passed.yml diff --git a/.github/workflows/all_check_passed.yml b/.github/workflows/all_check_passed.yml new file mode 100644 index 0000000..9f3a826 --- /dev/null +++ b/.github/workflows/all_check_passed.yml @@ -0,0 +1,11 @@ +name: All checks pass + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + allchecks: + runs-on: ubuntu-latest + steps: + - uses: wechuli/allcheckspassed@v1 From ffb675aa6628b85930d1610f6b722dfb37142ada Mon Sep 17 00:00:00 2001 From: Adrien Kantcheff <5028967+akantcheff@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:37:58 +0100 Subject: [PATCH 4/4] ci(merge): workflow to create merge pr upstream (#40) --- .github/workflows/create_merge_pr_upstream.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/create_merge_pr_upstream.yml diff --git a/.github/workflows/create_merge_pr_upstream.yml b/.github/workflows/create_merge_pr_upstream.yml new file mode 100644 index 0000000..fcaac2e --- /dev/null +++ b/.github/workflows/create_merge_pr_upstream.yml @@ -0,0 +1,16 @@ +name: Create Merge Pull Request Upstream + +on: + workflow_dispatch: + push: + branches: + - "[0-9]+.[0-9]+.x" + - "master" + - "release-*" + +jobs: + create-merge-pr: + uses: bonitasoft/github-workflows/.github/workflows/_reusable_create_merge_pr.yml@main + secrets: inherit + with: + labels: automerge