Skip to content

Commit

Permalink
fix: add logging for when ssh falls back to http (#1639)
Browse files Browse the repository at this point in the history
Co-authored-by: thomas williams <thomas.williams@thetradedesk.com>
  • Loading branch information
Alphy11 and thomas williams authored Sep 17, 2020
1 parent c982249 commit b4c5d0a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/get-git-auth-url.js
Original file line number Diff line number Diff line change
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 b4c5d0a

Please sign in to comment.