diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 115ed732d90..94fd118d4f5 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -82,9 +82,17 @@ jobs: with: name: 'build-artifact' + - name: Check if deploy is necessary + id: check_deploy + if: ${{ always() }} + run: | + if [[ ${{ needs.build.outputs.total_additions }} -le 100 || "${{ github.actor }}" == "dependabot[bot]" ]]; then + echo "Skipping deployment" + exit 0 + fi + - name: Deploy to precommit environment id: deploy - if: ${{ needs.build.outputs.total_additions > 100 && github.actor != 'dependabot[bot]' }} uses: einaregilsson/beanstalk-deploy@v22 with: application_name: Webapp diff --git a/Jenkinsfile b/Jenkinsfile index 4746d4d307d..c17ab7f5b22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,27 +85,34 @@ pipeline { } } } - - stage('Check GitHub Action Status') { - when { expression { BRANCH_NAME ==~ /PR-[0-9]+/ } } - steps { + stage('Check GitHub Action Status') { + when { expression { BRANCH_NAME ==~ /PR-[0-9]+/ } } + steps { timeout(time: 15, unit: 'MINUTES') { - script { - def commit_hash = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() - final String apiUrl = 'https://api.github.com/repos/wireapp/wire-webapp/actions/workflows/128602012/runs' - final String curlCmd = "curl -u \${CREDENTIALS} ${apiUrl}" - waitUntil { - final String output = sh(label: 'Check workflow', returnStdout: true, script: curlCmd) - final Object jsonData = readJSON(text: output) - final List workflowRuns = jsonData['workflow_runs'] - echo("Looking for hash ${commit_hash}") + script { + def commit_hash = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() + final String apiUrl = 'https://api.github.com/repos/wireapp/wire-webapp/actions/workflows/128602012/runs' + final String curlCmd = "curl -u \${CREDENTIALS} ${apiUrl}" + waitUntil { + final String output = sh(label: 'Check workflow', returnStdout: true, script: curlCmd) + final Object jsonData = readJSON(text: output) + final List workflowRuns = jsonData['workflow_runs'] + echo("Looking for hash ${commit_hash}") - return workflowRuns.any { run -> checkWorkflowRun(run, commit_hash) } + return workflowRuns.any { run -> + def result = checkWorkflowRun(run, commit_hash) + if (run['conclusion'] == 'cancelled') { + echo("GitHub Action was cancelled. Ending Jenkins pipeline.") + return true + } + + return result + } + } + } } } - } } - } stage('Check deployment') { steps {