Skip to content

Commit

Permalink
fix(github-actions): use GitHub PAT instead of GitHub App key in `cre…
Browse files Browse the repository at this point in the history
…ate-pr-for-changes`

Using the GitHub App key for Angular Robot does not retrieving a fork to
create PRs from. Switching to using a GitHub Personal Access Token in
order to be able to create PRs from a fork and not pollute the upstream
branches.
  • Loading branch information
gkalpak authored and devversion committed Sep 15, 2022
1 parent 639ed26 commit 5497ef9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7,633 deletions.
4 changes: 2 additions & 2 deletions github-actions/create-pr-for-changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ inputs:
To skip the automatic clean up of obsolete branches, set this option to `false`.
Example: `clean-up-branches: false`
angular-robot-key:
angular-robot-token:
required: true
description: The private key for the Angular Robot Github app. Used to authenticate with GitHub.
description: A GitHub access token for Angular Robot. Used to authenticate with GitHub.

outputs:
result:
Expand Down
1 change: 0 additions & 1 deletion github-actions/create-pr-for-changes/lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ts_library(
exclude = ["*.spec.ts"],
),
deps = [
"//github-actions:utils",
"//ng-dev/utils",
"@npm//@actions/core",
"@npm//@actions/github",
Expand Down
15 changes: 4 additions & 11 deletions github-actions/create-pr-for-changes/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {GithubConfig, setConfig} from '../../../ng-dev/utils/config.js';
import {AuthenticatedGitClient} from '../../../ng-dev/utils/git/authenticated-git-client.js';
import {GithubRepo} from '../../../ng-dev/utils/git/github.js';
import {getRepositoryGitUrl} from '../../../ng-dev/utils/git/github-urls.js';
import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js';

const enum ActionResult {
created = 'created',
Expand All @@ -18,8 +17,6 @@ main();

// Helpers
async function main(): Promise<void> {
let authToken: string | null = null;

try {
// Initialize outputs.
core.setOutput('result', ActionResult.nothing);
Expand All @@ -35,10 +32,10 @@ async function main(): Promise<void> {
};
setConfig(config);

// Configure the `AuthenticatedGitClient` to be authenticated with the token for the Angular
// Robot.
authToken = await getAuthTokenFor(ANGULAR_ROBOT);
AuthenticatedGitClient.configure(authToken);
// Configure the `AuthenticatedGitClient` to be authenticated with the provided GitHub access
// token for Angular Robot.
const accessToken = core.getInput('angular-robot-token', {required: true});
AuthenticatedGitClient.configure(accessToken);
/** The authenticated GitClient. */
const git = await AuthenticatedGitClient.get();
git.run(['config', 'user.email', '[email protected]']);
Expand Down Expand Up @@ -206,10 +203,6 @@ async function main(): Promise<void> {
core.setOutput('result', ActionResult.failed);
core.error(err);
core.setFailed(err.message);
} finally {
if (authToken !== null) {
await revokeActiveInstallationToken(authToken);
}
}
}

Expand Down
Loading

0 comments on commit 5497ef9

Please sign in to comment.