Skip to content

Commit 2fb2aaf

Browse files
committed
fix(travis): make sure repo is synced
1 parent 4f91ebb commit 2fb2aaf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/travis.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ const createTravisEnvVar = async ({
4040
})
4141
}
4242

43+
interface TravisUser {
44+
id: number
45+
login: string
46+
name: string
47+
github_id: number
48+
avatar_url: string
49+
education: boolean
50+
is_syncing: boolean
51+
synced_at: string
52+
}
53+
54+
const getCurrentTravisUser = async ({ travisClient }: { travisClient: TravisClient }): Promise<TravisUser> =>
55+
(await travisClient.get('user')).body
56+
4357
export async function initTravis({
4458
hasTests,
4559
repoName,
@@ -98,6 +112,14 @@ export async function initTravis({
98112
await writeFile('.travis.yml', yaml.dump(travisYaml))
99113
}
100114

115+
const travisUser = await getCurrentTravisUser({ travisClient })
116+
console.log('Triggering Travis sync of repositories')
117+
await travisClient.post(`user/${travisUser.id}/sync`)
118+
while ((await getCurrentTravisUser({ travisClient })).is_syncing) {
119+
console.log('Waiting for sync to finish...')
120+
await new Promise(resolve => setTimeout(resolve, 1000))
121+
}
122+
101123
console.log(`Activating repository at https://travis-ci.org/sourcegraph/${repoName}`)
102124
await travisClient.post(`/repo/sourcegraph%2F${repoName}/activate`)
103125

0 commit comments

Comments
 (0)