Skip to content

Commit

Permalink
Revert shifted API usage from actions/deploy-pages#136
Browse files Browse the repository at this point in the history
  • Loading branch information
cr313 committed Mar 17, 2023
1 parent 3e67d6e commit 827d28d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 34 deletions.
23 changes: 4 additions & 19 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1942,10 +1942,6 @@ function checkBypass(reqUrl) {
if (!reqUrl.hostname) {
return false;
}
const reqHost = reqUrl.hostname;
if (isLoopbackAddress(reqHost)) {
return true;
}
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
if (!noProxy) {
return false;
Expand All @@ -1971,24 +1967,13 @@ function checkBypass(reqUrl) {
.split(',')
.map(x => x.trim().toUpperCase())
.filter(x => x)) {
if (upperNoProxyItem === '*' ||
upperReqHosts.some(x => x === upperNoProxyItem ||
x.endsWith(`.${upperNoProxyItem}`) ||
(upperNoProxyItem.startsWith('.') &&
x.endsWith(`${upperNoProxyItem}`)))) {
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
return true;
}
}
return false;
}
exports.checkBypass = checkBypass;
function isLoopbackAddress(host) {
const hostLower = host.toLowerCase();
return (hostLower === 'localhost' ||
hostLower.startsWith('127.') ||
hostLower.startsWith('[::1]') ||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
}
//# sourceMappingURL=proxy.js.map

/***/ }),
Expand Down Expand Up @@ -9899,7 +9884,7 @@ async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, i
core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)

try {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments', {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployment', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
...payload
Expand All @@ -9917,7 +9902,7 @@ async function getPagesDeploymentStatus({ githubToken, deploymentId }) {

core.info('Getting Pages deployment status...')
try {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployments/{deploymentId}', {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployment/status/{deploymentId}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId
Expand All @@ -9935,7 +9920,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {

core.info('Canceling Pages deployment...')
try {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments/{deploymentId}/cancel', {
const response = await octokit.request('PUT /repos/{owner}/{repo}/pages/deployment/cancel/{deploymentId}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, i
core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)

try {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments', {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployment', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
...payload
Expand All @@ -131,7 +131,7 @@ async function getPagesDeploymentStatus({ githubToken, deploymentId }) {

core.info('Getting Pages deployment status...')
try {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployments/{deploymentId}', {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployment/status/{deploymentId}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId
Expand All @@ -149,7 +149,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {

core.info('Canceling Pages deployment...')
try {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments/{deploymentId}/cancel', {
const response = await octokit.request('PUT /repos/{owner}/{repo}/pages/deployment/cancel/{deploymentId}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId
Expand Down
22 changes: 11 additions & 11 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ describe('Deployment', () => {
})

const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})

Expand Down Expand Up @@ -138,14 +138,14 @@ describe('Deployment', () => {
})

const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt,
preview: true
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome',
preview_url: 'https://actions.drafts.github.io/is-awesome'
})
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Deployment', () => {
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })

const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA
})
Expand Down Expand Up @@ -225,18 +225,18 @@ describe('Deployment', () => {
})

const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})

const deploymentStatusScope = nock('https://api.github.com')
.get(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`)
.get(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`)
.reply(200, {
status: 'succeed'
})
Expand Down Expand Up @@ -279,18 +279,18 @@ describe('Deployment', () => {
})

const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})

const cancelDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}/cancel`)
.put(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/cancel/${process.env.GITHUB_SHA}`)
.reply(200, {})

core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
Expand Down

0 comments on commit 827d28d

Please sign in to comment.