Skip to content

Commit

Permalink
fix: add logging for when ssh falls back to http (semantic-release#1639)
Browse files Browse the repository at this point in the history
Co-authored-by: thomas williams <thomas.williams@thetradedesk.com>
  • Loading branch information
2 people authored and pull[bot] committed Sep 17, 2020
1 parent 6f16677 commit 5fb9927
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/get-git-auth-url.js
Expand Up @@ -2,6 +2,7 @@ const {parse, format} = require('url'); // eslint-disable-line node/no-deprecate
const {isNil} = require('lodash');
const hostedGitInfo = require('hosted-git-info');
const {verifyAuth} = require('./git');
const debug = require('debug')('semantic-release:get-git-auth-url');

/**
* Determine the the git repository URL to use to push, either:
Expand Down Expand Up @@ -42,8 +43,11 @@ module.exports = async ({cwd, env, branch, options: {repositoryUrl}}) => {

// Test if push is allowed without transforming the URL (e.g. is ssh keys are set up)
try {
debug('Verifying ssh auth by attempting to push to %s', repositoryUrl);
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
} catch (_) {
debug('SSH key auth failed, falling back to https.');

const envVar = Object.keys(GIT_TOKENS).find((envVar) => !isNil(env[envVar]));
const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`;

Expand Down

0 comments on commit 5fb9927

Please sign in to comment.