[tests] Don't run tests in forks (#3713)

There is no need to run the tests in a fork because when the forked repo submits a PR to this repo, the tests will run.
This commit is contained in:
Steven
2020-01-31 18:49:56 -05:00
committed by GitHub
parent 300558f24e
commit 5e8541b936
2 changed files with 11 additions and 2 deletions

View File

@@ -1,14 +1,15 @@
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const repo = process.env.GITHUB_REPOSITORY; // 'zeit/now'
const ref = process.env.GITHUB_REF.slice(11); // 'refs/heads/ci-cancel-previous', const ref = process.env.GITHUB_REF.slice(11); // 'refs/heads/ci-cancel-previous',
const sha = process.env.GITHUB_SHA; // 'a5d18518ea755ddc4212f47ec3448f59e0e7e3a5', const sha = process.env.GITHUB_SHA; // 'a5d18518ea755ddc4212f47ec3448f59e0e7e3a5',
const run = process.env.GITHUB_RUN_ID; // '33175268', const run = process.env.GITHUB_RUN_ID; // '33175268',
const event = process.env.GITHUB_EVENT_NAME; // 'push' const event = process.env.GITHUB_EVENT_NAME; // 'push'
const token = process.env.GITHUB_WORKFLOW_TOKEN; // access token with `public_repo` scope added to repo secrets const token = process.env.GITHUB_WORKFLOW_TOKEN; // access token with `public_repo` scope added to repo secrets
const workflow = 'continuous-integration.yml'; const workflow = 'continuous-integration.yml';
console.log({ ref, sha, run, event, workflow }); console.log({ repo, ref, sha, run, event, workflow });
const url = `https://api.github.com/repos/zeit/now/actions/workflows/${workflow}/runs`; const url = `https://api.github.com/repos/${repo}/actions/workflows/${workflow}/runs`;
const opts = { const opts = {
headers: { headers: {
Accept: 'application/vnd.github.v3+json', Accept: 'application/vnd.github.v3+json',

View File

@@ -2,6 +2,14 @@ const { execSync, spawn } = require('child_process');
const { join, relative } = require('path'); const { join, relative } = require('path');
const { readdirSync } = require('fs'); const { readdirSync } = require('fs');
if (
process.env.GITHUB_REPOSITORY &&
process.env.GITHUB_REPOSITORY !== 'zeit/now'
) {
console.log('Detected fork, skipping tests');
return;
}
process.chdir(join(__dirname, '..')); process.chdir(join(__dirname, '..'));
async function main() { async function main() {