leave comment if test fails (#2272)

This commit is contained in:
Karolina Rakoczy 2022-09-02 10:06:23 +02:00 committed by GitHub
parent 22e78bbd23
commit d13cf7d06d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -12,6 +12,7 @@ program
.option("--tests_status <tests_status>", `tests status`) .option("--tests_status <tests_status>", `tests status`)
.option("--version <version>", "version of a project") .option("--version <version>", "version of a project")
.option("--pull_request_number <pull_request_number>", "Pull Request number") .option("--pull_request_number <pull_request_number>", "Pull Request number")
.option("--auto_release <auto_release>", "is auto release")
.action(async options => { .action(async options => {
const octokit = new Octokit({ const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN, auth: process.env.GITHUB_TOKEN,
@ -53,7 +54,11 @@ program
process.exit(2); process.exit(2);
} }
if (isPatchRelease(options.version) && options.tests_status === "success") { if (
options.auto_release &&
isPatchRelease(options.version) &&
options.tests_status === "success"
) {
try { try {
await octokit.request( await octokit.request(
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge", "PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge",

View file

@ -144,7 +144,7 @@ jobs:
tag: ${{ steps.get-env-uri.outputs.ENV_URI }},${{ github.event.inputs.tags }} tag: ${{ steps.get-env-uri.outputs.ENV_URI }},${{ github.event.inputs.tags }}
run-tests-on-release: run-tests-on-release:
if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.environment != 'PROD' && github.event.client_payload.environment != 'ENTERPRISE'}} if: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.environment != 'PROD' && github.event.client_payload.environment != 'ENTERPRISE' && github.event.client_payload.project != 'DEMO'}}
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
status: ${{ job.status }} status: ${{ job.status }}
@ -199,7 +199,7 @@ jobs:
tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, Critical, https://v${{ steps.version.outputs.formatted_version }}.staging.saleor.cloud tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, Critical, https://v${{ steps.version.outputs.formatted_version }}.staging.saleor.cloud
add-review-and-merge-patch: add-review-and-merge-patch:
if: ${{github.event.client_payload.autoRelease}} if: ${{ always() && needs.run-tests-on-release.outputs.status != "skipped" && needs.run-tests-on-release.outputs.status != "cancelled" }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [run-tests-on-release] needs: [run-tests-on-release]
steps: steps:
@ -217,11 +217,12 @@ jobs:
cd .github/workflows cd .github/workflows
npm ci npm ci
- name: Add review and merge if patch - name: Add review and merge if patch DASHBOARD
env: env:
tests_status: ${{ needs.run-tests-on-release.outputs.status}} tests_status: ${{ needs.run-tests-on-release.outputs.status}}
version: ${{github.event.client_payload.version}} version: ${{github.event.client_payload.version}}
pull_request_number: ${{ github.event.client_payload.pullRequestNumber}} pull_request_number: ${{ github.event.client_payload.pullRequestNumber}}
auto_release: ${{github.event.client_payload.autoRelease}}
run: | run: |
export GITHUB_TOKEN=$( \ export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
@ -230,4 +231,5 @@ jobs:
node .github/workflows/approveAndMergeReleasePR.js \ node .github/workflows/approveAndMergeReleasePR.js \
--tests_status $tests_status \ --tests_status $tests_status \
--version $version \ --version $version \
--pull_request_number $pull_request_number --pull_request_number $pull_request_number \
--auto_release $auto_release