mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-29 17:34:53 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114f9cc1f8 | ||
|
|
0dfe0f0668 | ||
|
|
c7c77bb21c | ||
|
|
369d1aed92 | ||
|
|
4865e84b02 | ||
|
|
b627026553 | ||
|
|
9bd912c0ca | ||
|
|
ed034ea1c3 | ||
|
|
8f9a38d5e7 | ||
|
|
71b1669225 | ||
|
|
a87638c69c | ||
|
|
85d735dc73 | ||
|
|
2e87ed0ac6 |
@@ -11,7 +11,7 @@
|
|||||||
"SharedArrayBuffer": "readonly"
|
"SharedArrayBuffer": "readonly"
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018
|
"ecmaVersion": 2020
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"semi": ["error", "never"]
|
"semi": ["error", "never"]
|
||||||
|
|||||||
2
.github/CODEOWNERS
vendored
Normal file
2
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Default PR reviewers
|
||||||
|
* @actions/pages
|
||||||
34
.github/workflows/check-formatting.yml
vendored
Normal file
34
.github/workflows/check-formatting.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: Checking formatting
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
# This allows a subsequently queued workflow run to interrupt previous runs
|
||||||
|
concurrency:
|
||||||
|
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Node.JS
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Verify formatting
|
||||||
|
run: npm run format:check
|
||||||
34
.github/workflows/check-linter.yml
vendored
Normal file
34
.github/workflows/check-linter.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: Checking linter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
# This allows a subsequently queued workflow run to interrupt previous runs
|
||||||
|
concurrency:
|
||||||
|
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Node.JS
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Verify linter
|
||||||
|
run: npm run lint
|
||||||
@@ -1,24 +1,26 @@
|
|||||||
name: Release new action version
|
name: Release
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [edited]
|
types: [released]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
TAG_NAME:
|
TAG_NAME:
|
||||||
description: 'Tag name that the major tag will point to'
|
description: "Tag name that the major tag will point to"
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_tag:
|
update_tag:
|
||||||
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
||||||
environment:
|
|
||||||
name: releaseNewActionVersion
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
# Note: this environment is protected
|
||||||
|
name: Release
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
id: update-major-tag
|
id: update-major-tag
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid"
|
|
||||||
}
|
|
||||||
10
.prettierrc.yml
Normal file
10
.prettierrc.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Prettier (formatter) configuration
|
||||||
|
---
|
||||||
|
printWidth: 120
|
||||||
|
tabWidth: 2
|
||||||
|
useTabs: false
|
||||||
|
semi: false
|
||||||
|
singleQuote: true
|
||||||
|
trailingComma: none
|
||||||
|
bracketSpacing: true
|
||||||
|
arrowParens: avoid
|
||||||
1498
dist/index.js
vendored
1498
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
13
dist/licenses.txt
vendored
13
dist/licenses.txt
vendored
@@ -258,3 +258,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
uuid
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|||||||
51
package-lock.json
generated
51
package-lock.json
generated
@@ -10,7 +10,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^0.5.2",
|
"@actions/artifact": "^0.5.2",
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^1.9.1",
|
||||||
"@babel/plugin-transform-runtime": "^7.16.0",
|
"@babel/plugin-transform-runtime": "^7.16.0",
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"axios-retry": "^3.2.4",
|
"axios-retry": "^3.2.4",
|
||||||
@@ -42,11 +42,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.6.0",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||||
"integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
|
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
@@ -7210,6 +7219,14 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/v8-compile-cache": {
|
"node_modules/v8-compile-cache": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
||||||
@@ -7470,11 +7487,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.6.0",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||||
"integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
|
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"requires": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
@@ -12785,6 +12813,11 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||||
|
},
|
||||||
"v8-compile-cache": {
|
"v8-compile-cache": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^0.5.2",
|
"@actions/artifact": "^0.5.2",
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^1.9.1",
|
||||||
"@babel/plugin-transform-runtime": "^7.16.0",
|
"@babel/plugin-transform-runtime": "^7.16.0",
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"regenerator-runtime": "^0.13.9",
|
"regenerator-runtime": "^0.13.9",
|
||||||
@@ -27,7 +27,9 @@
|
|||||||
"lint": "eslint src",
|
"lint": "eslint src",
|
||||||
"prepare": "ncc build src/index.js -o dist --source-map --license licenses.txt && ncc build src/pre.js -o pre --source-map --license licenses.txt",
|
"prepare": "ncc build src/index.js -o dist --source-map --license licenses.txt && ncc build src/pre.js -o pre --source-map --license licenses.txt",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"all": "npm run lint && npm run prepare && npm run test"
|
"format": "prettier --write 'src/**/*.js'",
|
||||||
|
"format:check": "prettier --check 'src/**/*.js'",
|
||||||
|
"all": "npm run format && npm run lint && npm run prepare && npm run test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
1466
pre/index.js
1466
pre/index.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -258,3 +258,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
uuid
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ const axios = require('axios')
|
|||||||
const getContext = require('./context')
|
const getContext = require('./context')
|
||||||
|
|
||||||
const errorStatus = {
|
const errorStatus = {
|
||||||
'unknown_status' : 'Unable to get deployment status.',
|
unknown_status: 'Unable to get deployment status.',
|
||||||
'not_found' : 'Deployment not found.',
|
not_found: 'Deployment not found.',
|
||||||
'deployment_attempt_error' : 'Deployment temporarily failed, a retry will be automatically scheduled...'
|
deployment_attempt_error: 'Deployment temporarily failed, a retry will be automatically scheduled...'
|
||||||
}
|
}
|
||||||
|
|
||||||
class Deployment {
|
class Deployment {
|
||||||
@@ -38,7 +38,7 @@ class Deployment {
|
|||||||
const pagesDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment`
|
const pagesDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment`
|
||||||
const artifactExgUrl = `${this.runTimeUrl}_apis/pipelines/workflows/${this.workflowRun}/artifacts?api-version=6.0-preview`
|
const artifactExgUrl = `${this.runTimeUrl}_apis/pipelines/workflows/${this.workflowRun}/artifacts?api-version=6.0-preview`
|
||||||
core.info(`Artifact URL: ${artifactExgUrl}`)
|
core.info(`Artifact URL: ${artifactExgUrl}`)
|
||||||
const {data} = await axios.get(artifactExgUrl, {
|
const { data } = await axios.get(artifactExgUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.runTimeToken}`,
|
Authorization: `Bearer ${this.runTimeToken}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -47,7 +47,9 @@ class Deployment {
|
|||||||
core.info(JSON.stringify(data))
|
core.info(JSON.stringify(data))
|
||||||
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
||||||
if (!artifactRawUrl) {
|
if (!artifactRawUrl) {
|
||||||
throw new Error('No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.')
|
throw new Error(
|
||||||
|
'No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
||||||
@@ -71,7 +73,6 @@ class Deployment {
|
|||||||
this.deploymentInfo = response.data
|
this.deploymentInfo = response.data
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
core.info(error.stack)
|
core.info(error.stack)
|
||||||
|
|
||||||
// output raw error in debug mode.
|
// output raw error in debug mode.
|
||||||
@@ -81,20 +82,18 @@ class Deployment {
|
|||||||
if (error.response) {
|
if (error.response) {
|
||||||
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
||||||
if (error.response.status == 400) {
|
if (error.response.status == 400) {
|
||||||
let message = ""
|
let message = ''
|
||||||
if (error.response.data && error.response.data.message) {
|
if (error.response.data && error.response.data.message) {
|
||||||
message = error.response.data.message
|
message = error.response.data.message
|
||||||
} else {
|
} else {
|
||||||
message = error.response.data
|
message = error.response.data
|
||||||
}
|
}
|
||||||
errorMessage += `Responded with: ${message}`
|
errorMessage += `Responded with: ${message}`
|
||||||
}
|
} else if (error.response.status == 403) {
|
||||||
else if (error.response.status == 403) {
|
|
||||||
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
||||||
} else if (error.response.status == 404) {
|
} else if (error.response.status == 404) {
|
||||||
errorMessage += `Ensure GitHub Pages has been enabled.`
|
errorMessage += `Ensure GitHub Pages has been enabled.`
|
||||||
}
|
} else if (error.response.status >= 500) {
|
||||||
else if (error.response.status >= 500) {
|
|
||||||
errorMessage += `Server error, is githubstatus.com reporting a Pages outage? Please re-run the deployment at a later time.`
|
errorMessage += `Server error, is githubstatus.com reporting a Pages outage? Please re-run the deployment at a later time.`
|
||||||
}
|
}
|
||||||
throw errorMessage
|
throw errorMessage
|
||||||
@@ -107,10 +106,11 @@ class Deployment {
|
|||||||
// Poll the deployment endpoint for status
|
// Poll the deployment endpoint for status
|
||||||
async check() {
|
async check() {
|
||||||
try {
|
try {
|
||||||
const statusUrl = this.deploymentInfo != null ?
|
const statusUrl =
|
||||||
this.deploymentInfo["status_url"] :
|
this.deploymentInfo != null
|
||||||
`${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
? this.deploymentInfo['status_url']
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||||
|
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo['page_url'] : '')
|
||||||
const timeout = Number(core.getInput('timeout'))
|
const timeout = Number(core.getInput('timeout'))
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
const maxErrorCount = Number(core.getInput('error_count'))
|
||||||
@@ -140,9 +140,11 @@ class Deployment {
|
|||||||
// Fall into permanent error, it may be caused by ongoing incident or malicious deployment content or exhausted automatic retry times.
|
// Fall into permanent error, it may be caused by ongoing incident or malicious deployment content or exhausted automatic retry times.
|
||||||
core.setFailed('Deployment failed, try again later.')
|
core.setFailed('Deployment failed, try again later.')
|
||||||
break
|
break
|
||||||
} else if(res.data.status == 'deployment_content_failed') {
|
} else if (res.data.status == 'deployment_content_failed') {
|
||||||
// The uploaded artifact is invalid.
|
// The uploaded artifact is invalid.
|
||||||
core.setFailed('Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.')
|
core.setFailed(
|
||||||
|
'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.'
|
||||||
|
)
|
||||||
break
|
break
|
||||||
} else if (errorStatus[res.data.status]) {
|
} else if (errorStatus[res.data.status]) {
|
||||||
// A temporary error happened, will query the status again
|
// A temporary error happened, will query the status again
|
||||||
@@ -156,7 +158,7 @@ class Deployment {
|
|||||||
|
|
||||||
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
if (errorReportingInterval < 1000 * 15) {
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
errorReportingInterval = errorReportingInterval << 1 | 1
|
errorReportingInterval = (errorReportingInterval << 1) | 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// reset the error reporting interval once get the proper status back.
|
// reset the error reporting interval once get the proper status back.
|
||||||
@@ -166,13 +168,19 @@ class Deployment {
|
|||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= maxErrorCount) {
|
||||||
core.info('Too many errors, aborting!')
|
core.info('Too many errors, aborting!')
|
||||||
core.setFailed('Failed with status code: ' + res.status)
|
core.setFailed('Failed with status code: ' + res.status)
|
||||||
break
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle timeout
|
// Handle timeout
|
||||||
if (Date.now() - startTime >= timeout) {
|
if (Date.now() - startTime >= timeout) {
|
||||||
core.info('Timeout reached, aborting!')
|
core.info('Timeout reached, aborting!')
|
||||||
core.setFailed('Timeout reached, aborting!')
|
core.setFailed('Timeout reached, aborting!')
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,5 +191,34 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cancel() {
|
||||||
|
// Don't attemp to cancel if no deployment was created
|
||||||
|
if (!this.requestedDeployment) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
module.exports = {Deployment}
|
|
||||||
|
// Cancel the deployment
|
||||||
|
try {
|
||||||
|
const pagesCancelDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/cancel/${this.buildVersion}`
|
||||||
|
await axios.put(
|
||||||
|
pagesCancelDeployEndpoint,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/vnd.github.v3+json',
|
||||||
|
Authorization: `Bearer ${this.githubToken}`,
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
core.info(`Deployment cancelled with ${pagesCancelDeployEndpoint}`)
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error)
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
core.info(JSON.stringify(error.response.data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = { Deployment }
|
||||||
|
|||||||
32
src/index.js
32
src/index.js
@@ -6,39 +6,17 @@ require('regenerator-runtime/runtime')
|
|||||||
|
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
// const github = require('@actions/github'); // TODO: Not used until we publish API endpoint to the @action/github package
|
// const github = require('@actions/github'); // TODO: Not used until we publish API endpoint to the @action/github package
|
||||||
const axios = require('axios')
|
|
||||||
|
|
||||||
const {Deployment} = require('./deployment')
|
const { Deployment } = require('./deployment')
|
||||||
const deployment = new Deployment()
|
const deployment = new Deployment()
|
||||||
|
|
||||||
// TODO: If the artifact hasn't been created, we can create it and upload to artifact storage ourselves
|
|
||||||
// const tar = require('tar')
|
|
||||||
|
|
||||||
async function cancelHandler(evtOrExitCodeOrError) {
|
async function cancelHandler(evtOrExitCodeOrError) {
|
||||||
try {
|
await deployment.cancel()
|
||||||
if (deployment.requestedDeployment) {
|
|
||||||
const pagesCancelDeployEndpoint = `${deployment.githubApiUrl}/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/cancel/${process.env.GITHUB_SHA}`
|
|
||||||
await axios.put(
|
|
||||||
pagesCancelDeployEndpoint,
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Accept: 'application/vnd.github.v3+json',
|
|
||||||
Authorization: `Bearer ${deployment.githubToken}`,
|
|
||||||
'Content-type': 'application/json'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
core.info(`Deployment cancelled with ${pagesCancelDeployEndpoint}`)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Deployment cancellation failed', e)
|
|
||||||
}
|
|
||||||
process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError)
|
process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
let idToken = ""
|
let idToken = ''
|
||||||
try {
|
try {
|
||||||
idToken = await core.getIDToken()
|
idToken = await core.getIDToken()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -59,8 +37,8 @@ process.on('SIGINT', cancelHandler)
|
|||||||
process.on('SIGTERM', cancelHandler)
|
process.on('SIGTERM', cancelHandler)
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
const emitTelemetry = core.getInput("emit_telemetry")
|
const emitTelemetry = core.getInput('emit_telemetry')
|
||||||
if (emitTelemetry === "true") {
|
if (emitTelemetry === 'true') {
|
||||||
require('./pre')
|
require('./pre')
|
||||||
} else {
|
} else {
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const axios = require('axios')
|
|||||||
|
|
||||||
const { expect, jest } = require('@jest/globals')
|
const { expect, jest } = require('@jest/globals')
|
||||||
|
|
||||||
const {Deployment} = require('./deployment')
|
const { Deployment } = require('./deployment')
|
||||||
|
|
||||||
describe('with all environment variables set', () => {
|
describe('with all environment variables set', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -35,8 +35,8 @@ describe('with variables missing', () => {
|
|||||||
it('execution fails if there are missing variables', done => {
|
it('execution fails if there are missing variables', done => {
|
||||||
delete process.env.ACTIONS_RUNTIME_URL
|
delete process.env.ACTIONS_RUNTIME_URL
|
||||||
const ip = path.join(__dirname, './index.js')
|
const ip = path.join(__dirname, './index.js')
|
||||||
cp.exec(`node ${ip}`, {env: process.env}, (err, stdout) => {
|
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
|
||||||
expect(stdout).toBe("")
|
expect(stdout).toBe('')
|
||||||
expect(err).toBeTruthy()
|
expect(err).toBeTruthy()
|
||||||
expect(err.code).toBe(1)
|
expect(err.code).toBe(1)
|
||||||
done()
|
done()
|
||||||
@@ -80,10 +80,16 @@ describe('create', () => {
|
|||||||
|
|
||||||
it('can successfully create a deployment', async () => {
|
it('can successfully create a deployment', async () => {
|
||||||
process.env.GITHUB_SHA = 'valid-build-version'
|
process.env.GITHUB_SHA = 'valid-build-version'
|
||||||
const fakeJwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNjllMWIxOC1jOGFiLTRhZGQtOGYxOC03MzVlMzVjZGJhZjAiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjIiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM4ODI4MDI4LCJleHAiOjE2Mzg4Mjg5MjgsImlhdCI6MTYzODgyODYyOH0.1wyupfxu1HGoTyIqatYg0hIxy2-0bMO-yVlmLSMuu2w'
|
const fakeJwt =
|
||||||
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNjllMWIxOC1jOGFiLTRhZGQtOGYxOC03MzVlMzVjZGJhZjAiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjIiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM4ODI4MDI4LCJleHAiOjE2Mzg4Mjg5MjgsImlhdCI6MTYzODgyODYyOH0.1wyupfxu1HGoTyIqatYg0hIxy2-0bMO-yVlmLSMuu2w'
|
||||||
const scope = nock(`http://my-url`)
|
const scope = nock(`http://my-url`)
|
||||||
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
|
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
|
||||||
.reply(200, { value: [ {url: 'https://another-artifact.com', name: 'another-artifact'}, { url: 'https://fake-artifact.com', name: 'github-pages' }] })
|
.reply(200, {
|
||||||
|
value: [
|
||||||
|
{ url: 'https://another-artifact.com', name: 'another-artifact' },
|
||||||
|
{ url: 'https://fake-artifact.com', name: 'github-pages' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
||||||
axios.post = jest.fn().mockResolvedValue('test')
|
axios.post = jest.fn().mockResolvedValue('test')
|
||||||
@@ -109,9 +115,7 @@ describe('create', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(core.setFailed).not.toHaveBeenCalled()
|
expect(core.setFailed).not.toHaveBeenCalled()
|
||||||
expect(core.info).toHaveBeenCalledWith(
|
expect(core.info).toHaveBeenCalledWith('Created deployment for valid-build-version')
|
||||||
'Created deployment for valid-build-version'
|
|
||||||
)
|
|
||||||
|
|
||||||
scope.done()
|
scope.done()
|
||||||
})
|
})
|
||||||
@@ -131,7 +135,6 @@ describe('create', () => {
|
|||||||
try {
|
try {
|
||||||
deployment.create()
|
deployment.create()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
||||||
expect(axios.post).toBeCalledWith(
|
expect(axios.post).toBeCalledWith(
|
||||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/deployment',
|
'https://api.github.com/repos/paper-spa/is-awesome/pages/deployment',
|
||||||
{
|
{
|
||||||
@@ -147,15 +150,12 @@ describe('create', () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(core.info).toHaveBeenLastCalledWith(
|
expect(core.info).toHaveBeenLastCalledWith('Failed to create deployment for invalid-build-version.')
|
||||||
'Failed to create deployment for invalid-build-version.'
|
|
||||||
)
|
|
||||||
expect(core.setFailed).toHaveBeenCalledWith({ status: 400 })
|
expect(core.setFailed).toHaveBeenCalledWith({ status: 400 })
|
||||||
|
|
||||||
scope.done()
|
scope.done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('check', () => {
|
describe('check', () => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ axiosRetry(axios, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const {Deployment} = require('./deployment')
|
const { Deployment } = require('./deployment')
|
||||||
|
|
||||||
async function emitTelemetry() {
|
async function emitTelemetry() {
|
||||||
// All variables we need from the runtime are set in the Deployment constructor
|
// All variables we need from the runtime are set in the Deployment constructor
|
||||||
@@ -26,7 +26,7 @@ async function emitTelemetry() {
|
|||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
telemetryUrl,
|
telemetryUrl,
|
||||||
{github_run_id: deployment.workflowRun},
|
{ github_run_id: deployment.workflowRun },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
@@ -54,4 +54,4 @@ async function main() {
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
module.exports = {emitTelemetry}
|
module.exports = { emitTelemetry }
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ const core = require('@actions/core')
|
|||||||
const process = require('process')
|
const process = require('process')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
|
|
||||||
const {expect, jest} = require('@jest/globals')
|
const { expect, jest } = require('@jest/globals')
|
||||||
|
|
||||||
const {emitTelemetry} = require('./pre')
|
const { emitTelemetry } = require('./pre')
|
||||||
|
|
||||||
describe('emitTelemetry', () => {
|
describe('emitTelemetry', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user