diff --git a/.github/workflows/call-check-version-changed.yml b/.github/workflows/call-check-version-changed.yml new file mode 100644 index 0000000..047c869 --- /dev/null +++ b/.github/workflows/call-check-version-changed.yml @@ -0,0 +1,49 @@ +name: "Create artifacts" +on: + workflow_call: + outputs: + IS_SAME_VERSIONS: + description: "The name of requested build variant" + value: ${{ jobs.compare_versions.outputs.IS_SAME_VERSIONS }} +jobs: + # ${{ jobs.get_version_from_target_branch.outputs.TARGET_VERSION }} + get_version_from_target_branch: + name: Get version from target branch + runs-on: ubuntu-latest + outputs: + TARGET_VERSION: ${{ steps.properties.outputs.makeevrserg-project-version-string }} + steps: + - name: Checkout Git repo + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + # ${{ steps.properties.outputs.makeevrserg-project-version-string }} + - uses: christian-draeger/read-properties@1.1.1 + id: properties + with: + path: './gradle.properties' + properties: 'makeevrserg.project.name makeevrserg.project.version.string' + + # ${{ jobs.get_version_from_current_branch.outputs.CURRENT_VERSION }} + get_version_from_current_branch: + name: Get version from current branch + runs-on: ubuntu-latest + outputs: + CURRENT_VERSION: ${{ steps.properties.outputs.makeevrserg-project-version-string }} + steps: + - name: Checkout Git repo + uses: actions/checkout@v4 + + # ${{ steps.properties.outputs.makeevrserg-project-version-string }} + - uses: christian-draeger/read-properties@1.1.1 + id: properties + with: + path: './gradle.properties' + properties: 'makeevrserg.project.name makeevrserg.project.version.string' + + compare_versions: + name: "Compare versions ${{ jobs.get_version_from_target_branch.outputs.TARGET_VERSION }} and ${{ jobs.get_version_from_current_branch.outputs.CURRENT_VERSION }}" + runs-on: ubuntu-latest + outputs: + IS_SAME_VERSIONS: ${{ jobs.get_version_from_target_branch.outputs.TARGET_VERSION }} == ${{ jobs.get_version_from_current_branch.outputs.CURRENT_VERSION }} \ No newline at end of file diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index a3eb129..13c6a95 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -5,15 +5,36 @@ on: - 'develop' - 'master' - 'rc' + merge_group: + +# Concurrency strategy: +# github.workflow: distinguish this workflow from others +# github.event_name: distinguish `push` event from `pull_request` and 'merge_group' event +# github.ref_name: distinguish branch +# github.repository: distinguish owner+repository +# +# Reference: +# https://docs.github.com/en/actions/using-jobs/using-concurrency +# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{github.ref_name}}-${{github.repository}} + cancel-in-progress: true + jobs: gradle_validation: name: "Gradle Wrapper" uses: ./.github/workflows/call-gradle-wrapper-validation.yml + check_versions: + name: "Check version changed" + needs: gradle_validation + uses: ./.github/workflows/call-check-version-changed.yml detekt_validation: name: "Detekt" - needs: gradle_validation + if: ${{ jobs.check_versions.outputs.IS_SAME_VERSIONS }} == true + needs: [ gradle_validation,check_versions ] uses: ./.github/workflows/call-detekt-validation.yml tests_validation: name: "Tests" - needs: gradle_validation + if: ${{ jobs.check_versions.outputs.IS_SAME_VERSIONS }} == true + needs: [ gradle_validation,check_versions ] uses: ./.github/workflows/call-tests-validation.yml \ No newline at end of file