Fix comments on release PRs (#2293)
* Fix comments on release PRs * Update .github/workflows/approveAndMergeReleasePR.js Co-authored-by: Mika <mikail.kocak@saleor.io> Co-authored-by: Mika <mikail.kocak@saleor.io>
This commit is contained in:
parent
4ee5eb7795
commit
c524221a0f
2 changed files with 37 additions and 42 deletions
17
.github/workflows/approveAndMergeReleasePR.js
vendored
17
.github/workflows/approveAndMergeReleasePR.js
vendored
|
@ -13,6 +13,7 @@ program
|
||||||
.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")
|
.option("--auto_release <auto_release>", "is auto release")
|
||||||
|
.option("--dashboard_url <dashboard_url>", "Cypress dashboard url")
|
||||||
.action(async options => {
|
.action(async options => {
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
auth: process.env.GITHUB_TOKEN,
|
auth: process.env.GITHUB_TOKEN,
|
||||||
|
@ -32,11 +33,10 @@ program
|
||||||
const commitId = pullRequest.data.merge_commit_sha;
|
const commitId = pullRequest.data.merge_commit_sha;
|
||||||
const requestBody =
|
const requestBody =
|
||||||
options.tests_status === "success"
|
options.tests_status === "success"
|
||||||
? "Cypress test passed"
|
? `Cypress tests passed. See results at ${options.dashboard_url}`
|
||||||
: "Some tests failed, need manual approve";
|
: `Some tests failed, need manual approve. See results at ${options.dashboard_url}`;
|
||||||
const event = options.tests_status === "success" ? "APPROVE" : "COMMENT";
|
const event = "COMMENT";
|
||||||
|
|
||||||
try {
|
|
||||||
await octokit.request(
|
await octokit.request(
|
||||||
"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews",
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews",
|
||||||
{
|
{
|
||||||
|
@ -49,17 +49,12 @@ program
|
||||||
comments: [],
|
comments: [],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
error(e.message);
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
options.auto_release &&
|
options.auto_release &&
|
||||||
isPatchRelease(options.version) &&
|
isPatchRelease(options.version) &&
|
||||||
options.tests_status === "success"
|
options.tests_status === "success"
|
||||||
) {
|
) {
|
||||||
try {
|
|
||||||
await octokit.request(
|
await octokit.request(
|
||||||
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge",
|
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge",
|
||||||
{
|
{
|
||||||
|
@ -68,10 +63,6 @@ program
|
||||||
pull_number: pullNumber,
|
pull_number: pullNumber,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
|
||||||
error(e.message);
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.parse();
|
.parse();
|
||||||
|
|
22
.github/workflows/tests-nightly.yml
vendored
22
.github/workflows/tests-nightly.yml
vendored
|
@ -63,7 +63,6 @@ jobs:
|
||||||
${{ runner.os }}-qa-${{ env.cache-name }}-
|
${{ runner.os }}-qa-${{ env.cache-name }}-
|
||||||
${{ runner.os }}-qa-
|
${{ runner.os }}-qa-
|
||||||
${{ runner.os }}-
|
${{ runner.os }}-
|
||||||
|
|
||||||
- name: Write config file
|
- name: Write config file
|
||||||
id: write-config-file
|
id: write-config-file
|
||||||
env:
|
env:
|
||||||
|
@ -87,9 +86,11 @@ jobs:
|
||||||
MSG_MINIMAL: true
|
MSG_MINIMAL: true
|
||||||
|
|
||||||
run-tests-in-parallel:
|
run-tests-in-parallel:
|
||||||
needs: revert-automation-env-to-snap
|
needs: ['revert-automation-env-to-snap']
|
||||||
if: ${{ always() && github.event_name != 'repository_dispatch' }} #Wait for revert-automation-env-to-snap, bot run always, even if skipped
|
if: ${{ always() && github.event_name != 'repository_dispatch' }} #Wait for revert-automation-env-to-snap, bot run always, even if skipped
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
status: ${{ steps.cypress.outcome }}
|
||||||
container: cypress/browsers:node14.16.0-chrome89-ff86
|
container: cypress/browsers:node14.16.0-chrome89-ff86
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -105,7 +106,6 @@ jobs:
|
||||||
if: ${{ github.event.inputs.environment == 'Other' }}
|
if: ${{ github.event.inputs.environment == 'Other' }}
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=ENV_URI::${{github.event.inputs.otherEnvironment}}"
|
echo "::set-output name=ENV_URI::${{github.event.inputs.otherEnvironment}}"
|
||||||
|
|
||||||
- name: Get env
|
- name: Get env
|
||||||
id: get-env-uri
|
id: get-env-uri
|
||||||
env:
|
env:
|
||||||
|
@ -113,13 +113,14 @@ jobs:
|
||||||
TYPED_ENV_URI: ''
|
TYPED_ENV_URI: ''
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=ENV_URI::${{ steps.get-typed-env-uri.outputs.ENV_URI || github.event.inputs.environment || env.DEFAULT_ENV_URI }}"
|
echo "::set-output name=ENV_URI::${{ steps.get-typed-env-uri.outputs.ENV_URI || github.event.inputs.environment || env.DEFAULT_ENV_URI }}"
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 14
|
||||||
|
|
||||||
- name: Cypress run
|
- name: Cypress run
|
||||||
|
id: cypress
|
||||||
|
continue-on-error: true
|
||||||
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch'}}
|
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch'}}
|
||||||
uses: cypress-io/github-action@v4
|
uses: cypress-io/github-action@v4
|
||||||
env:
|
env:
|
||||||
|
@ -143,11 +144,13 @@ jobs:
|
||||||
record: true
|
record: true
|
||||||
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' && github.event.client_payload.project != 'DEMO'}}
|
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: ${{ steps.cypress.outcome }}
|
||||||
|
dashboard_url: ${{ steps.cypress.outputs.dashboardUrl }}
|
||||||
container: cypress/browsers:node14.16.0-chrome89-ff86
|
container: cypress/browsers:node14.16.0-chrome89-ff86
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -162,7 +165,6 @@ jobs:
|
||||||
version: ${{github.event.client_payload.version}}
|
version: ${{github.event.client_payload.version}}
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=ref::$(echo $version | grep -ohE "[0-9]\.[0-9]+" )"
|
echo "::set-output name=ref::$(echo $version | grep -ohE "[0-9]\.[0-9]+" )"
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -176,6 +178,8 @@ jobs:
|
||||||
echo "::set-output name=formatted_version::$(echo $version | grep -ohE "[0-9]\.[0-9]+" | sed s/\\.// )"
|
echo "::set-output name=formatted_version::$(echo $version | grep -ohE "[0-9]\.[0-9]+" | sed s/\\.// )"
|
||||||
|
|
||||||
- name: Cypress run - automatically
|
- name: Cypress run - automatically
|
||||||
|
id: cypress
|
||||||
|
continue-on-error: true
|
||||||
uses: cypress-io/github-action@v4
|
uses: cypress-io/github-action@v4
|
||||||
env:
|
env:
|
||||||
API_URI: https://v${{ steps.version.outputs.formatted_version }}.staging.saleor.cloud/graphql/
|
API_URI: https://v${{ steps.version.outputs.formatted_version }}.staging.saleor.cloud/graphql/
|
||||||
|
@ -199,7 +203,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: ${{ always() && needs.run-tests-on-release.outputs.status != 'skipped' && needs.run-tests-on-release.outputs.status != 'cancelled' }}
|
if: ${{ always() && (needs.run-tests-on-release.outputs.status == 'success' || needs.run-tests-on-release.outputs.status == 'failure') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [run-tests-on-release]
|
needs: [run-tests-on-release]
|
||||||
steps:
|
steps:
|
||||||
|
@ -216,20 +220,20 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd .github/workflows
|
cd .github/workflows
|
||||||
npm ci
|
npm ci
|
||||||
|
|
||||||
- name: Add review and merge if patch DASHBOARD
|
- 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}}
|
auto_release: ${{github.event.client_payload.autoRelease}}
|
||||||
|
dashboard_url: ${{ needs.run-tests-on-release.outputs.dashboard_url}}
|
||||||
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 \
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
--auto_release $auto_release
|
||||||
|
--dashboard_url $dashboard_url
|
Loading…
Reference in a new issue