Skip to content

ci: use authenticated git url for pushing updated changelog entries #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Setting `persist-credentials: false` prevents the github-action account from being the
# account that is attempted to be used for authentication, instead the remote is set to
# an authenticated URL.
persist-credentials: false
- uses: ./tools/local-actions/changelog
with:
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}
5 changes: 3 additions & 2 deletions github-actions/slash-commands/main.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ng-dev/utils/git/github-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const GITHUB_TOKEN_GENERATE_URL = 'https://github.com/settings/tokens/new
/** Adds the provided token to the given Github HTTPs remote url. */
export function addTokenToGitHttpsUrl(githubHttpsUrl: string, token: string) {
const url = new URL(githubHttpsUrl);
url.username = token;
url.password = token;
url.username = '_';
return url.href;
}

Expand Down
4 changes: 2 additions & 2 deletions ng-dev/utils/testing/virtual-git-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export function getBranchPushMatcher(options: BranchPushMatchParameters) {
const {targetRepo, targetBranch, baseBranch, baseRepo, expectedCommits} = options;
return jasmine.objectContaining({
remote: {
repoUrl: `https://abc123@github.com/${targetRepo.owner}/${targetRepo.name}.git`,
repoUrl: `https://_:abc123@github.com/${targetRepo.owner}/${targetRepo.name}.git`,
name: `refs/heads/${targetBranch}`,
},
head: jasmine.objectContaining({
newCommits: expectedCommits,
ref: {
repoUrl: `https://abc123@github.com/${baseRepo.owner}/${baseRepo.name}.git`,
repoUrl: `https://_:abc123@github.com/${baseRepo.owner}/${baseRepo.name}.git`,
name: baseBranch,
},
}),
Expand Down
3 changes: 2 additions & 1 deletion tools/local-actions/changelog/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {AuthenticatedGitClient} from '../../../../ng-dev/utils/git/authenticated
import {ANGULAR_ROBOT, getAuthTokenFor} from '../../../../github-actions/utils';
import {GithubConfig, setConfig} from '../../../../ng-dev/utils/config';
import {ReleaseConfig} from '../../../../ng-dev/release/config/index';
import {addTokenToGitHttpsUrl} from '../../../../ng-dev/utils/git/github-urls';

/** The tag used for tracking the last time the changlog was generated. */
const lastChangelogTag = 'most-recent-changelog-generation';
Expand Down Expand Up @@ -46,7 +47,7 @@ async function run(): Promise<void> {
AuthenticatedGitClient.configure(await getAuthTokenFor(ANGULAR_ROBOT));
/** The authenticed GitClient. */
const git = AuthenticatedGitClient.get();
git.run(['config', 'user.email', '56403804+angular-robot[bot]@users.noreply.github.com']);
git.run(['config', 'user.email', 'angular-robot@google.com']);
git.run(['config', 'user.name', 'Angular Robot']);

/** The full path to the changelog file. */
Expand Down
7 changes: 4 additions & 3 deletions tools/local-actions/changelog/main.js

Large diffs are not rendered by default.