From 1ce6a774445d85aaf760e8136464bc71d021c084 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 22 Sep 2020 11:36:21 -0700 Subject: [PATCH] chore: regenerate common templates (#210) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/e5ba338a-4e18-4137-b9ad-10798d036f2f/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: https://github.com/googleapis/synthtool/commit/80003a3de2d8a75f5b47cb2e77e018f7f0f776cc Source-Link: https://github.com/googleapis/synthtool/commit/538a68019eb4a36a0cdfa4021f324dd01b784395 Source-Link: https://github.com/googleapis/synthtool/commit/019c7168faa0e56619f792693a8acdb30d6de19b Source-Link: https://github.com/googleapis/synthtool/commit/968465a1cad496e1292ef4584a054a35f756ff94 --- .github/CODEOWNERS | 2 + .github/workflows/auto-release.yaml | 69 +++++++++++++++++++++++++++++ .kokoro/release/stage.cfg | 31 ++----------- synth.metadata | 5 ++- 4 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/auto-release.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6137bef2..30fdb7b9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,5 +4,7 @@ # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax +* @googleapis/yoshi-java + # The java-samples-reviewers team is the default owner for samples changes samples/**/*.java @googleapis/java-samples-reviewers diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml new file mode 100644 index 00000000..d26427e4 --- /dev/null +++ b/.github/workflows/auto-release.yaml @@ -0,0 +1,69 @@ +on: + pull_request: +name: auto-release +jobs: + approve: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3.0.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + debug: true + script: | + // only approve PRs from release-please[bot] + if (context.payload.pull_request.user.login !== "release-please[bot]") { + return; + } + + // only approve PRs like "chore: release " + if ( !context.payload.pull_request.title.startsWith("chore: release") ) { + return; + } + + // trigger auto-release when + // 1) it is a SNAPSHOT release (auto-generated post regular release) + // 2) there are dependency updates only + // 3) there are no open dependency update PRs in this repo (to avoid multiple releases) + if ( + context.payload.pull_request.body.includes("Fix") || + context.payload.pull_request.body.includes("Build") || + context.payload.pull_request.body.includes("Documentation") || + context.payload.pull_request.body.includes("BREAKING CHANGES") || + context.payload.pull_request.body.includes("Features") + ) { + console.log( "Not auto-releasing since it is not a dependency-update-only release." ); + return; + } + + const promise = github.pulls.list.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + const open_pulls = await github.paginate(promise) + + if ( open_pulls.length > 1 && !context.payload.pull_request.title.includes("SNAPSHOT") ) { + for ( const pull of open_pulls ) { + if ( pull.title.startsWith("deps: update dependency") ) { + console.log( "Not auto-releasing yet since there are dependency update PRs open in this repo." ); + return; + } + } + } + + // approve release PR + await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Rubber stamped release!', + pull_number: context.payload.pull_request.number, + event: 'APPROVE' + }); + + // attach kokoro:force-run and automerge labels + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: ['kokoro:force-run', 'automerge'] + }); \ No newline at end of file diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg index 71a21f08..fb1edb09 100644 --- a/.kokoro/release/stage.cfg +++ b/.kokoro/release/stage.cfg @@ -13,32 +13,7 @@ action { } } -# Fetch the token needed for reporting release status to GitHub -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "yoshi-automation-github-key" - } - } -} - -# Fetch magictoken to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "releasetool-magictoken" - } - } -} - -# Fetch api key to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "magic-github-proxy-api-key" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/synth.metadata b/synth.metadata index 75e394c0..967ef482 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-websecurityscanner.git", - "sha": "2339d7047280ecbccfdcec56101cdf6a91a1e81c" + "sha": "8b1527fb53b5a8d16c5daeb96ff5c9dcb452d2e4" } }, { @@ -35,7 +35,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "9602086c6c5b05db77950c7f7495a2a3868f3537" + "sha": "80003a3de2d8a75f5b47cb2e77e018f7f0f776cc" } } ], @@ -76,6 +76,7 @@ ".github/PULL_REQUEST_TEMPLATE.md", ".github/release-please.yml", ".github/trusted-contribution.yml", + ".github/workflows/auto-release.yaml", ".github/workflows/ci.yaml", ".github/workflows/samples.yaml", ".kokoro/build.bat",