From f9590d84d389bd19b9aeb404d61197e650b3ce4e Mon Sep 17 00:00:00 2001 From: stephwang Date: Thu, 24 Sep 2020 18:00:15 -0400 Subject: [PATCH] chore(ci): verify autorelease release PR content --- .../.github/workflows/auto-release.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/synthtool/gcp/templates/java_library/.github/workflows/auto-release.yaml b/synthtool/gcp/templates/java_library/.github/workflows/auto-release.yaml index 45e1a58b5..522b0164f 100644 --- a/synthtool/gcp/templates/java_library/.github/workflows/auto-release.yaml +++ b/synthtool/gcp/templates/java_library/.github/workflows/auto-release.yaml @@ -21,6 +21,24 @@ jobs: return; } + // only approve PRs with pom.xml and versions.txt changes + const filesPromise = github.pulls.listFiles.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + const changed_files = await github.paginate(filesPromise) + + if ( changed_files.length < 1 ) { + console.log( "Not proceeding since PR is empty!" ) + return; + } + + if ( !changed_files.some(v => v.filename.includes("pom")) || !changed_files.some(v => v.filename.includes("versions.txt")) ) { + console.log( "PR file changes do not have pom.xml or versions.txt -- something is wrong. PTAL!" ) + return; + } + // trigger auto-release when // 1) it is a SNAPSHOT release (auto-generated post regular release) // 2) there are dependency updates only