Skip to content

Commit

Permalink
fix(travis): make sure repo is synced
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Aug 4, 2018
1 parent 4f91ebb commit 2fb2aaf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/travis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ const createTravisEnvVar = async ({
})
}

interface TravisUser {
id: number
login: string
name: string
github_id: number
avatar_url: string
education: boolean
is_syncing: boolean
synced_at: string
}

const getCurrentTravisUser = async ({ travisClient }: { travisClient: TravisClient }): Promise<TravisUser> =>
(await travisClient.get('user')).body

export async function initTravis({
hasTests,
repoName,
Expand Down Expand Up @@ -98,6 +112,14 @@ export async function initTravis({
await writeFile('.travis.yml', yaml.dump(travisYaml))
}

const travisUser = await getCurrentTravisUser({ travisClient })
console.log('Triggering Travis sync of repositories')
await travisClient.post(`user/${travisUser.id}/sync`)
while ((await getCurrentTravisUser({ travisClient })).is_syncing) {
console.log('Waiting for sync to finish...')
await new Promise(resolve => setTimeout(resolve, 1000))
}

console.log(`Activating repository at https://travis-ci.org/sourcegraph/${repoName}`)
await travisClient.post(`/repo/sourcegraph%2F${repoName}/activate`)

Expand Down

0 comments on commit 2fb2aaf

Please sign in to comment.