modified to use proxy input

This commit is contained in:
Jeremy Daley
2023-02-10 01:28:34 -05:00
parent 37538b280c
commit 4bfe138e84
8 changed files with 581 additions and 13 deletions

View File

@@ -1,11 +1,12 @@
const axios = require('axios')
const core = require('@actions/core')
const HPA = require('https-proxy-agent')
function getApiBaseUrl() {
return process.env.GITHUB_API_URL || 'https://api.github.com'
}
async function enablePagesSite({ repositoryNwo, githubToken }) {
async function enablePagesSite({ repositoryNwo, githubToken, proxy }) {
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
try {
@@ -13,6 +14,7 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
pagesEndpoint,
{ build_type: 'workflow' },
{
...(proxy ? {httpsAgent: HPA(proxy)} : {}),
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`,
@@ -32,10 +34,11 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
}
}
async function getPagesSite({ repositoryNwo, githubToken }) {
async function getPagesSite({ repositoryNwo, githubToken, proxy }) {
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
const response = await axios.get(pagesEndpoint, {
...(proxy ? {httpsAgent: HPA(proxy)} : {}),
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`

View File

@@ -7,6 +7,7 @@ function getRequiredVars() {
githubToken: core.getInput('token'),
staticSiteGenerator: core.getInput('static_site_generator'),
generatorConfigFile: core.getInput('generator_config_file'),
proxy: core.getInput('proxy'),
enablement: core.getInput('enablement') === 'true'
}
}