Compare commits

...

5 Commits

Author SHA1 Message Date
James M. Greene
f27bcc1584 Backporting PR #197 to the v1.x release line 2023-08-09 15:50:48 -05:00
James M. Greene
eb68e76f70 Backporting PR #187 to the v1.x release line 2023-08-09 15:48:55 -05:00
James M. Greene
dcda0bb2bc Merge pull request #139 from actions/revert-api-shift
Revert shifted Deployments API endpoint usage
2023-03-17 11:48:46 -05:00
James M. Greene
7ed610198d Update distributables with correct dependencies 2023-03-17 11:21:12 -05:00
James M. Greene
30c6e00b35 Revert shifted API usage from https://github.com/actions/deploy-pages/pull/136
Fixes https://github.com/actions/deploy-pages/issues/137
2023-03-17 11:18:26 -05:00
5 changed files with 20 additions and 30 deletions

13
dist/index.js vendored
View File

@@ -9899,7 +9899,7 @@ async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, i
core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`) core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
...payload ...payload
@@ -9917,7 +9917,7 @@ async function getPagesDeploymentStatus({ githubToken, deploymentId }) {
core.info('Getting Pages deployment status...') core.info('Getting Pages deployment status...')
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
deploymentId deploymentId
@@ -9935,7 +9935,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {
core.info('Canceling Pages deployment...') core.info('Canceling Pages deployment...')
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
deploymentId deploymentId
@@ -10017,6 +10017,7 @@ const temporaryErrorStatus = {
const finalErrorStatus = { const finalErrorStatus = {
deployment_failed: 'Deployment failed, try again later.', deployment_failed: 'Deployment failed, try again later.',
deployment_perms_error: 'Deployment failed. Please ensure that the file permissions are correct.',
deployment_content_failed: deployment_content_failed:
'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.', 'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.',
deployment_cancelled: 'Deployment cancelled.', deployment_cancelled: 'Deployment cancelled.',
@@ -10079,9 +10080,6 @@ class Deployment {
} catch (error) { } catch (error) {
core.error(error.stack) core.error(error.stack)
// output raw error in debug mode.
core.debug(JSON.stringify(error))
// build customized error message based on server response // build customized error message based on server response
if (error.response) { if (error.response) {
let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. ` let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. `
@@ -10162,9 +10160,6 @@ class Deployment {
} catch (error) { } catch (error) {
core.error(error.stack) core.error(error.stack)
// output raw error in debug mode.
core.debug(JSON.stringify(error))
// build customized error message based on server response // build customized error message based on server response
if (error.response) { if (error.response) {
errorStatus = error.status || error.response.status errorStatus = error.status || error.response.status

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -113,7 +113,7 @@ async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, i
core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`) core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
...payload ...payload
@@ -131,7 +131,7 @@ async function getPagesDeploymentStatus({ githubToken, deploymentId }) {
core.info('Getting Pages deployment status...') core.info('Getting Pages deployment status...')
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
deploymentId deploymentId
@@ -149,7 +149,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {
core.info('Canceling Pages deployment...') core.info('Canceling Pages deployment...')
try { 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, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
deploymentId deploymentId

View File

@@ -17,6 +17,7 @@ const temporaryErrorStatus = {
const finalErrorStatus = { const finalErrorStatus = {
deployment_failed: 'Deployment failed, try again later.', deployment_failed: 'Deployment failed, try again later.',
deployment_perms_error: 'Deployment failed. Please ensure that the file permissions are correct.',
deployment_content_failed: deployment_content_failed:
'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.', 'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.',
deployment_cancelled: 'Deployment cancelled.', deployment_cancelled: 'Deployment cancelled.',
@@ -79,9 +80,6 @@ class Deployment {
} catch (error) { } catch (error) {
core.error(error.stack) core.error(error.stack)
// output raw error in debug mode.
core.debug(JSON.stringify(error))
// build customized error message based on server response // build customized error message based on server response
if (error.response) { if (error.response) {
let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. ` let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. `
@@ -162,9 +160,6 @@ class Deployment {
} catch (error) { } catch (error) {
core.error(error.stack) core.error(error.stack)
// output raw error in debug mode.
core.debug(JSON.stringify(error))
// build customized error message based on server response // build customized error message based on server response
if (error.response) { if (error.response) {
errorStatus = error.status || error.response.status errorStatus = error.status || error.response.status

View File

@@ -100,13 +100,13 @@ describe('Deployment', () => {
}) })
const createDeploymentScope = nock('https://api.github.com') 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', artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA, pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt oidc_token: fakeJwt
}) })
.reply(200, { .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' page_url: 'https://actions.github.io/is-awesome'
}) })
@@ -138,14 +138,14 @@ describe('Deployment', () => {
}) })
const createDeploymentScope = nock('https://api.github.com') 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', artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA, pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt, oidc_token: fakeJwt,
preview: true preview: true
}) })
.reply(200, { .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', page_url: 'https://actions.github.io/is-awesome',
preview_url: 'https://actions.drafts.github.io/is-awesome' preview_url: 'https://actions.drafts.github.io/is-awesome'
}) })
@@ -192,7 +192,7 @@ describe('Deployment', () => {
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] }) .reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
const createDeploymentScope = nock('https://api.github.com') 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', artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA pages_build_version: process.env.GITHUB_SHA
}) })
@@ -225,18 +225,18 @@ describe('Deployment', () => {
}) })
const createDeploymentScope = nock('https://api.github.com') 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', artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA, pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt oidc_token: fakeJwt
}) })
.reply(200, { .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' page_url: 'https://actions.github.io/is-awesome'
}) })
const deploymentStatusScope = nock('https://api.github.com') 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, { .reply(200, {
status: 'succeed' status: 'succeed'
}) })
@@ -279,18 +279,18 @@ describe('Deployment', () => {
}) })
const createDeploymentScope = nock('https://api.github.com') 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', artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA, pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt oidc_token: fakeJwt
}) })
.reply(200, { .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' page_url: 'https://actions.github.io/is-awesome'
}) })
const cancelDeploymentScope = nock('https://api.github.com') 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, {}) .reply(200, {})
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt) core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)