diff --git a/src/createPullRequest.ts b/src/createPullRequest.ts deleted file mode 100644 index db12c22..0000000 --- a/src/createPullRequest.ts +++ /dev/null @@ -1,69 +0,0 @@ -import * as core from '@actions/core' -import Octokit from './getOctokit' -import {Base64} from 'js-base64' - -export interface CreatePROpts { - owner: string - repo: string - username: string - missingFiles: string[] - templates?: {[key: string]: string} - baseBranch: string -} - -type Octo = InstanceType - -export const DEFAULT_TEMPLATES: {[key: string]: string} = { - 'README.md': "This is a README!" -} - -export async function createPullRequest( - client: Octo, - options: CreatePROpts -): Promise { - const branchName = `repolinter/add-missing-files-${Date.now()}` - const templates = options.templates || DEFAULT_TEMPLATES - - try { - const baseRef = await client.git.getRef({ - owner: options.owner, - repo: options.repo, - ref: `heads/${options.baseBranch}` - }) - - await client.git.createRef({ - owner: options.owner, - repo: options.repo, - ref: `refs/heads/${branchName}`, - sha: baseRef.data.object.sha - }) - - for (const file of options.missingFiles) { - if (templates[file]) { - await client.repos.createOrUpdateFileContents({ - owner: options.owner, - repo: options.repo, - path: file, - message: `Add ${file} template`, - content: Base64.encode(templates[file]), - branch: branchName - }) - } - } - - const pr = await client.pulls.create({ - owner: options.owner, - repo: options.repo, - title: 'Add missing repository files', - body: "This PR adds the following template files that were detected as missing by Repolinter", - head: branchName, - base: options.baseBranch - }) - - core.info(`Created PR #${pr.data.number}`) - return pr.data.number - } catch (error) { - core.error('Failed to create pull request') - throw error - } -} diff --git a/src/main.ts b/src/main.ts index 2be9e87..0449076 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,6 @@ import { import * as fs from 'fs' import getConfig from './getConfig' import createOrUpdateIssue from './createorUpdateIssue' -import {createPullRequest} from './createPullRequest' function getInputs(): {[key: string]: string} { return { @@ -152,7 +151,7 @@ export default async function run(disableRetry?: boolean): Promise { changes: [ { files: { - "test.md": "this is a test markdown!" + "test.md": "this is a test markdown but now with an edit so lets see what happens now" }, commit: "this is a test commit" }