mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 22:29:45 +11:00
removing proxy-secret
This commit is contained in:
parent
464d7eda7a
commit
495aa57b75
5 changed files with 7 additions and 23 deletions
3
.github/workflows/integration.yml
vendored
3
.github/workflows/integration.yml
vendored
|
|
@ -57,7 +57,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
message: |
|
message: |
|
||||||
**It works!**
|
**It works!**
|
||||||
proxy-url: https://add-pr-comment-bot-73luvmwygq-uc.a.run.app
|
proxy-url: https://add-pr-comment-proxy-73luvmwygq-uc.a.run.app
|
||||||
proxy-secret: I636uHaB/NpwKMSyMjwsfmdabBE5Khjgh2po9oSy49TOa9eQwsQhEDRY9MLoGo9I9UtvftJgmxPJl1g0RjX1sA==
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
repo-token-user-login: "github-actions[bot]"
|
repo-token-user-login: "github-actions[bot]"
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ jobs:
|
||||||
message: |
|
message: |
|
||||||
**Howdie!**
|
**Howdie!**
|
||||||
proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app
|
proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app
|
||||||
proxy-secret: foobar
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,6 @@ inputs:
|
||||||
proxy-url:
|
proxy-url:
|
||||||
description: "Proxy URL for comment creation"
|
description: "Proxy URL for comment creation"
|
||||||
required: false
|
required: false
|
||||||
proxy-secret:
|
|
||||||
description: "A secret to use for authenticating against the proxy"
|
|
||||||
required: false
|
|
||||||
branding:
|
branding:
|
||||||
icon: message-circle
|
icon: message-circle
|
||||||
color: purple
|
color: purple
|
||||||
|
|
|
||||||
|
|
@ -41,23 +41,19 @@ interface CreateCommentProxyParams {
|
||||||
repo: string
|
repo: string
|
||||||
issueNumber: number
|
issueNumber: number
|
||||||
proxyUrl: string
|
proxyUrl: string
|
||||||
proxySecret: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const createCommentProxy = async (params: CreateCommentProxyParams): Promise<CreateIssueCommentResponseData | null> => {
|
const createCommentProxy = async (params: CreateCommentProxyParams): Promise<CreateIssueCommentResponseData | null> => {
|
||||||
const {repoToken, owner, repo, issueNumber, body, proxyUrl, proxySecret} = params
|
const {repoToken, owner, repo, issueNumber, body, proxyUrl} = params
|
||||||
|
|
||||||
const http = new HttpClient('http-client-add-pr-comment')
|
const http = new HttpClient('http-client-add-pr-comment')
|
||||||
|
|
||||||
const additionalHeaders: RequestHeaders = {
|
|
||||||
authorization: `basic ${Buffer.from(proxySecret + ':').toString('base64')}`,
|
|
||||||
['temporary-github-token']: repoToken,
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await http.postJson<CreateIssueCommentResponseData>(
|
const response = await http.postJson<CreateIssueCommentResponseData>(
|
||||||
`${proxyUrl}/repos/${owner}/${repo}/issues/${issueNumber}/comments`,
|
`${proxyUrl}/repos/${owner}/${repo}/issues/${issueNumber}/comments`,
|
||||||
{body},
|
{body},
|
||||||
additionalHeaders,
|
{
|
||||||
|
['temporary-github-token']: repoToken,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return response.result
|
return response.result
|
||||||
|
|
@ -84,7 +80,6 @@ const isMessagePresent = (
|
||||||
interface AddPrCommentInputs {
|
interface AddPrCommentInputs {
|
||||||
allowRepeats: boolean
|
allowRepeats: boolean
|
||||||
message: string
|
message: string
|
||||||
proxySecret?: string
|
|
||||||
proxyUrl?: string
|
proxyUrl?: string
|
||||||
repoToken?: string
|
repoToken?: string
|
||||||
repoTokenUserLogin?: string
|
repoTokenUserLogin?: string
|
||||||
|
|
@ -94,7 +89,6 @@ const getInputs = (): AddPrCommentInputs => {
|
||||||
return {
|
return {
|
||||||
allowRepeats: Boolean(core.getInput('allow-repeats') === 'true'),
|
allowRepeats: Boolean(core.getInput('allow-repeats') === 'true'),
|
||||||
message: core.getInput('message'),
|
message: core.getInput('message'),
|
||||||
proxySecret: core.getInput('proxy-secret'),
|
|
||||||
proxyUrl: core.getInput('proxy-url').replace(/\/$/, ''),
|
proxyUrl: core.getInput('proxy-url').replace(/\/$/, ''),
|
||||||
repoToken: core.getInput('repo-token') || process.env['GITHUB_TOKEN'],
|
repoToken: core.getInput('repo-token') || process.env['GITHUB_TOKEN'],
|
||||||
repoTokenUserLogin: core.getInput('repo-token-user-login'),
|
repoTokenUserLogin: core.getInput('repo-token-user-login'),
|
||||||
|
|
@ -103,7 +97,7 @@ const getInputs = (): AddPrCommentInputs => {
|
||||||
|
|
||||||
const run = async (): Promise<void> => {
|
const run = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const {allowRepeats, message, repoToken, repoTokenUserLogin, proxyUrl, proxySecret} = getInputs()
|
const {allowRepeats, message, repoToken, repoTokenUserLogin, proxyUrl} = getInputs()
|
||||||
|
|
||||||
if (!repoToken) {
|
if (!repoToken) {
|
||||||
throw new Error('no github token provided, set one with the repo-token input or GITHUB_TOKEN env variable')
|
throw new Error('no github token provided, set one with the repo-token input or GITHUB_TOKEN env variable')
|
||||||
|
|
@ -160,10 +154,6 @@ const run = async (): Promise<void> => {
|
||||||
|
|
||||||
if (shouldCreateComment) {
|
if (shouldCreateComment) {
|
||||||
if (proxyUrl) {
|
if (proxyUrl) {
|
||||||
if (!proxySecret) {
|
|
||||||
throw new Error('proxy-url defined, but proxy-secret is missing')
|
|
||||||
}
|
|
||||||
|
|
||||||
await createCommentProxy({
|
await createCommentProxy({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
|
|
@ -171,7 +161,6 @@ const run = async (): Promise<void> => {
|
||||||
body: message,
|
body: message,
|
||||||
repoToken,
|
repoToken,
|
||||||
proxyUrl,
|
proxyUrl,
|
||||||
proxySecret,
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await octokit.issues.createComment({
|
await octokit.issues.createComment({
|
||||||
|
|
|
||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue