mirror of
https://github.com/actions/deploy-pages.git
synced 2025-12-08 08:06:15 +00:00
publish to actions org
This commit is contained in:
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
dist/
|
||||
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"jest": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"semi": ["error", "never"]
|
||||
}
|
||||
}
|
||||
44
.github/workflows/check-dist.yml
vendored
Normal file
44
.github/workflows/check-dist.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file using `ncc`
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: npm run prepare
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
24
.github/workflows/test.yml
vendored
Normal file
24
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Run Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set Node.JS
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test
|
||||
67
.gitignore
vendored
Normal file
67
.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
node_modules/
|
||||
|
||||
# Editors
|
||||
.vscode/
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Other Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
10
.prettierrc.json
Normal file
10
.prettierrc.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 GitHub, Inc.
|
||||
|
||||
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.
|
||||
17
README.md
Normal file
17
README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Deploy-Pages
|
||||
|
||||
This deploys artifacts to GitHub Pages.
|
||||
|
||||
# Scope
|
||||
|
||||
⚠️ Official support for building Pages with Actions is in public beta at the moment. The scope is currently limited to **public repositories only**.
|
||||
|
||||
# Usage
|
||||
|
||||
See [action.yml](action.yml)
|
||||
|
||||
<!-- TODO: document custom workflow -->
|
||||
|
||||
# License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||
23
action.yml
Normal file
23
action.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
name: 'Deploy to GitHub Pages'
|
||||
description: 'A GitHub Action to deploy an artifact to GitHub Pages'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
pre: 'pre/index.js'
|
||||
inputs:
|
||||
token:
|
||||
description: 'GitHub token'
|
||||
default: ${{ github.token }}
|
||||
required: true
|
||||
timeout:
|
||||
description: 'Time in milliseconds after which to timeout and cancel the deployment (default: 10 minutes)'
|
||||
required: false
|
||||
default: "600000"
|
||||
error_count:
|
||||
description: 'Maximum number of status report errors before cancelling a deployment (default: 10)'
|
||||
required: false
|
||||
default: "10"
|
||||
reporting_interval:
|
||||
description: 'Time in milliseconds between two deployment status report (default: 1 second)'
|
||||
required: false
|
||||
default: "1000"
|
||||
1
babel.config.js
Normal file
1
babel.config.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {presets: ['@babel/preset-env']}
|
||||
6870
dist/index.js
vendored
Normal file
6870
dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
204
dist/licenses.txt
vendored
Normal file
204
dist/licenses.txt
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
@actions/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
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.
|
||||
|
||||
|
||||
axios
|
||||
MIT
|
||||
Copyright (c) 2014-present Matt Zabriskie
|
||||
|
||||
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.
|
||||
|
||||
|
||||
debug
|
||||
MIT
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
follow-redirects
|
||||
MIT
|
||||
Copyright 2014–present Olivier Lalonde <olalonde@gmail.com>, James Talmage <james@talmage.io>, Ruben Verborgh
|
||||
|
||||
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.
|
||||
|
||||
|
||||
has-flag
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
ms
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
regenerator-runtime
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present, Facebook, Inc.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
supports-color
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
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.
|
||||
1
dist/sourcemap-register.js
vendored
Normal file
1
dist/sourcemap-register.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
jest.config.js
Normal file
5
jest.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
transform: {
|
||||
'^.+\\.(js|jsx)$': 'babel-jest'
|
||||
}
|
||||
}
|
||||
12959
package-lock.json
generated
Normal file
12959
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
package.json
Normal file
46
package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "deploy-pages",
|
||||
"version": "0.0.1",
|
||||
"description": "Deploy an actions artifact to GitHub Pages",
|
||||
"main": "./dist/index.js",
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^0.5.2",
|
||||
"@actions/core": "^1.6.0",
|
||||
"@babel/plugin-transform-runtime": "^7.16.0",
|
||||
"axios": "^0.24.0",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"axios-retry": "^3.2.4",
|
||||
"tar": "^6.1.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.16.0",
|
||||
"@github/prettier-config": "0.0.4",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-github": "^4.3.4",
|
||||
"jest": "^27.3.1",
|
||||
"nock": "^13.2.0",
|
||||
"prettier": "^2.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"test": "jest",
|
||||
"all": "npm run lint && npm run prepare && npm run test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/paper-spa/deploy-pages.git"
|
||||
},
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
"Pages"
|
||||
],
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/paper-spa/deploy-pages/issues"
|
||||
},
|
||||
"homepage": "https://github.com/paper-spa/deploy-pages#readme"
|
||||
}
|
||||
7401
pre/index.js
Normal file
7401
pre/index.js
Normal file
File diff suppressed because it is too large
Load Diff
1
pre/index.js.map
Normal file
1
pre/index.js.map
Normal file
File diff suppressed because one or more lines are too long
260
pre/licenses.txt
Normal file
260
pre/licenses.txt
Normal file
@@ -0,0 +1,260 @@
|
||||
@actions/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
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.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@babel/runtime
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie 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.
|
||||
|
||||
|
||||
axios
|
||||
MIT
|
||||
Copyright (c) 2014-present Matt Zabriskie
|
||||
|
||||
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.
|
||||
|
||||
|
||||
axios-retry
|
||||
Apache-2.0
|
||||
Copyright 2019 Softonic International S.A.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
debug
|
||||
MIT
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
follow-redirects
|
||||
MIT
|
||||
Copyright 2014–present Olivier Lalonde <olalonde@gmail.com>, James Talmage <james@talmage.io>, Ruben Verborgh
|
||||
|
||||
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.
|
||||
|
||||
|
||||
has-flag
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
is-retry-allowed
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
ms
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
regenerator-runtime
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present, Facebook, Inc.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
supports-color
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
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.
|
||||
1
pre/sourcemap-register.js
Normal file
1
pre/sourcemap-register.js
Normal file
File diff suppressed because one or more lines are too long
26
src/context.js
Normal file
26
src/context.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const core = require('@actions/core')
|
||||
|
||||
// Load variables from Actions runtime
|
||||
function getRequiredVars() {
|
||||
return {
|
||||
runTimeUrl: process.env.ACTIONS_RUNTIME_URL,
|
||||
workflowRun: process.env.GITHUB_RUN_ID,
|
||||
runTimeToken: process.env.ACTIONS_RUNTIME_TOKEN,
|
||||
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
||||
buildVersion: process.env.GITHUB_SHA,
|
||||
buildActor: process.env.GITHUB_ACTOR,
|
||||
actionsId: process.env.GITHUB_ACTION,
|
||||
githubToken: core.getInput('token')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function getContext() {
|
||||
const requiredVars = getRequiredVars()
|
||||
for (const variable in requiredVars) {
|
||||
if (requiredVars[variable] === undefined) {
|
||||
throw new Error(`${variable} is undefined. Cannot continue.`)
|
||||
}
|
||||
}
|
||||
core.debug('all variables are set')
|
||||
return requiredVars
|
||||
}
|
||||
130
src/deployment.js
Normal file
130
src/deployment.js
Normal file
@@ -0,0 +1,130 @@
|
||||
require('regenerator-runtime/runtime')
|
||||
|
||||
const core = require('@actions/core')
|
||||
const axios = require('axios')
|
||||
|
||||
// All variables we need from the runtime are loaded here
|
||||
const getContext = require('./context')
|
||||
|
||||
class Deployment {
|
||||
constructor() {
|
||||
const context = getContext()
|
||||
this.runTimeUrl = context.runTimeUrl
|
||||
this.repositoryNwo = context.repositoryNwo
|
||||
this.runTimeToken = context.runTimeToken
|
||||
this.buildVersion = context.buildVersion
|
||||
this.buildActor = context.buildActor
|
||||
this.actionsId = context.workflowRun
|
||||
this.githubToken = context.githubToken
|
||||
this.workflowRun = context.workflowRun
|
||||
this.requestedDeployment = false
|
||||
}
|
||||
|
||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||
// by creating a deployment with that artifact
|
||||
async create(idToken) {
|
||||
try {
|
||||
core.info(`Actor: ${this.buildActor}`)
|
||||
core.info(`Action ID: ${this.actionsId}`)
|
||||
const pagesDeployEndpoint = `https://api.github.com/repos/${this.repositoryNwo}/pages/deployment`
|
||||
const artifactExgUrl = `${this.runTimeUrl}_apis/pipelines/workflows/${this.workflowRun}/artifacts?api-version=6.0-preview`
|
||||
core.info(`Artifact URL: ${artifactExgUrl}`)
|
||||
const {data} = await axios.get(artifactExgUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.runTimeToken}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
core.info(JSON.stringify(data))
|
||||
if (data.value.length == 0) {
|
||||
throw new Error('No uploaded artifact was found!')
|
||||
}
|
||||
const artifactUrl = `${data.value[0].url}&%24expand=SignedContent`
|
||||
const payload = {
|
||||
artifact_url: artifactUrl,
|
||||
pages_build_version: this.buildVersion,
|
||||
oidc_token: idToken
|
||||
}
|
||||
core.info(`Creating deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
|
||||
const response = await axios.post(pagesDeployEndpoint, payload, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
Authorization: `Bearer ${this.githubToken}`,
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
this.requestedDeployment = true
|
||||
core.info(`Created deployment for ${this.buildVersion}`)
|
||||
core.info(JSON.stringify(response.data))
|
||||
} catch (error) {
|
||||
core.info(`Failed to create deployment for ${this.buildVersion}.`)
|
||||
core.setFailed(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Poll the deployment endpoint for status
|
||||
async check() {
|
||||
try {
|
||||
const statusUrl = `https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
||||
const timeout = core.getInput('timeout')
|
||||
const reportingInterval = core.getInput('reporting_interval')
|
||||
const maxErrorCount = core.getInput('error_count')
|
||||
var startTime = Date.now()
|
||||
var errorCount = 0
|
||||
|
||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||
while (true) {
|
||||
// Handle reporting interval
|
||||
if (reportingInterval > 0) {
|
||||
await new Promise(r => setTimeout(r, reportingInterval))
|
||||
}
|
||||
|
||||
// Check status
|
||||
var res = await axios.get(statusUrl, {
|
||||
headers: {
|
||||
Authorization: `token ${this.githubToken}`
|
||||
}
|
||||
})
|
||||
|
||||
if (res.data.status == 'succeed') {
|
||||
core.info('Reported success!')
|
||||
core.setOutput('status', 'succeed')
|
||||
break
|
||||
} else if (res.data.status == 'deployment_failed') {
|
||||
// Fall into permanent error, it may be caused by ongoing incident or malicious deployment content or exhausted automatic retry times.
|
||||
core.info('Deployment failed, try again later.')
|
||||
core.setOutput('status', 'failed')
|
||||
break
|
||||
} else if (res.data.status == 'deployment_attempt_error') {
|
||||
// A temporary error happened, a retry will be scheduled automatically.
|
||||
core.info(
|
||||
'Deployment temporarily failed, a retry will be automatically scheduled...'
|
||||
)
|
||||
} else {
|
||||
core.info('Current status: ' + res.data.status)
|
||||
}
|
||||
|
||||
if (res.status != 200) {
|
||||
errorCount++
|
||||
}
|
||||
|
||||
if (errorCount >= maxErrorCount) {
|
||||
core.info('Too many errors, aborting!')
|
||||
core.setFailed('Failed with status code: ' + res.status)
|
||||
break
|
||||
}
|
||||
}
|
||||
// Handle timeout
|
||||
if (Date.now() - startTime >= timeout) {
|
||||
core.info('Timeout reached, aborting!')
|
||||
core.setFailed('Timeout reached, aborting!')
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {Deployment}
|
||||
55
src/index.js
Normal file
55
src/index.js
Normal file
@@ -0,0 +1,55 @@
|
||||
require('regenerator-runtime/runtime')
|
||||
|
||||
// This package assumes a site has already been built and the files exist in the current workspace
|
||||
// If there's an artifact named `artifact.tar`, it can upload that to actions on its own,
|
||||
// without the user having to do the tar process themselves.
|
||||
|
||||
const core = require('@actions/core')
|
||||
// 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 = 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) {
|
||||
try {
|
||||
if (deployment.requestedDeployment) {
|
||||
const pagesCancelDeployEndpoint = `https://api.github.com/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 ${process.env.GITHUB_TOKEN}`,
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
core.info(`Deployment cancelled with ${pagesCancelDeployEndpoint}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.info('Deployment cancellation failed', e)
|
||||
}
|
||||
process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const idToken = await core.getIDToken()
|
||||
await deployment.create(idToken)
|
||||
await deployment.check()
|
||||
} catch (error) {
|
||||
core.setFailed(error)
|
||||
}
|
||||
}
|
||||
|
||||
// Register signal handlers for workflow cancellation
|
||||
process.on('SIGINT', cancelHandler)
|
||||
process.on('SIGTERM', cancelHandler)
|
||||
|
||||
// Main
|
||||
main()
|
||||
221
src/index.test.js
Normal file
221
src/index.test.js
Normal file
@@ -0,0 +1,221 @@
|
||||
const core = require('@actions/core')
|
||||
const process = require('process')
|
||||
const cp = require('child_process')
|
||||
const path = require('path')
|
||||
const nock = require('nock')
|
||||
const axios = require('axios')
|
||||
|
||||
const { expect, jest } = require('@jest/globals')
|
||||
|
||||
const {Deployment} = require('./deployment')
|
||||
|
||||
describe('with all environment variables set', () => {
|
||||
beforeEach(() => {
|
||||
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
||||
process.env.GITHUB_RUN_ID = '123'
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
||||
process.env.GITHUB_TOKEN = 'gha-token'
|
||||
process.env.GITHUB_SHA = '123abc'
|
||||
process.env.GITHUB_ACTOR = 'monalisa'
|
||||
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
||||
process.env.GITHUB_ACTION_PATH = 'something'
|
||||
})
|
||||
|
||||
it('Executes cleanly', done => {
|
||||
const ip = path.join(__dirname, './index.js')
|
||||
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
|
||||
expect(stdout).toMatch(/::debug::all variables are set/)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with variables missing', () => {
|
||||
it('execution fails if there are missing variables', done => {
|
||||
delete process.env.ACTIONS_RUNTIME_URL
|
||||
const ip = path.join(__dirname, './index.js')
|
||||
cp.exec(`node ${ip}`, {env: process.env}, (err, stdout) => {
|
||||
expect(stdout).toBe("")
|
||||
expect(err).toBeTruthy()
|
||||
expect(err.code).toBe(1)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('create', () => {
|
||||
beforeAll(() => {
|
||||
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
||||
process.env.GITHUB_RUN_ID = '123'
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
||||
process.env.GITHUB_TOKEN = 'gha-token'
|
||||
process.env.GITHUB_SHA = '123abc'
|
||||
process.env.GITHUB_ACTOR = 'monalisa'
|
||||
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
||||
process.env.GITHUB_ACTION_PATH = 'something'
|
||||
|
||||
jest.spyOn(core, 'setOutput').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
|
||||
jest.spyOn(core, 'setFailed').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
// Mock error/warning/info/debug
|
||||
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||
})
|
||||
|
||||
it('can successfully create a deployment', async () => {
|
||||
process.env.GITHUB_SHA = 'valid-build-version'
|
||||
const fakeJwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNjllMWIxOC1jOGFiLTRhZGQtOGYxOC03MzVlMzVjZGJhZjAiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjIiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM4ODI4MDI4LCJleHAiOjE2Mzg4Mjg5MjgsImlhdCI6MTYzODgyODYyOH0.1wyupfxu1HGoTyIqatYg0hIxy2-0bMO-yVlmLSMuu2w'
|
||||
const scope = nock(`http://my-url`)
|
||||
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
|
||||
.reply(200, { value: [{ url: 'https://fake-artifact.com' }] })
|
||||
|
||||
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
||||
axios.post = jest.fn().mockResolvedValue('test')
|
||||
|
||||
// Create the deployment
|
||||
const deployment = new Deployment()
|
||||
await deployment.create(fakeJwt)
|
||||
|
||||
expect(axios.post).toBeCalledWith(
|
||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/deployment',
|
||||
{
|
||||
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
|
||||
pages_build_version: 'valid-build-version',
|
||||
oidc_token: fakeJwt
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
Authorization: 'Bearer ',
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
expect(core.setFailed).not.toHaveBeenCalled()
|
||||
expect(core.info).toHaveBeenCalledWith(
|
||||
'Created deployment for valid-build-version'
|
||||
)
|
||||
|
||||
scope.done()
|
||||
})
|
||||
|
||||
it('Reports errors with failed deployments', async () => {
|
||||
process.env.GITHUB_SHA = 'invalid-build-version'
|
||||
const scope = nock(`http://my-url`)
|
||||
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
|
||||
.reply(200, { value: [{ url: 'https://invalid-artifact.com' }] })
|
||||
|
||||
axios.post = jest.fn().mockRejectedValue({
|
||||
status: 400
|
||||
})
|
||||
|
||||
// Create the deployment
|
||||
const deployment = new Deployment()
|
||||
try {
|
||||
deployment.create()
|
||||
} catch (err) {
|
||||
|
||||
expect(axios.post).toBeCalledWith(
|
||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/deployment',
|
||||
{
|
||||
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
|
||||
pages_build_version: 'invalid-build-version'
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
Authorization: 'Bearer ',
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
expect(core.info).toHaveBeenLastCalledWith(
|
||||
'Failed to create deployment for invalid-build-version.'
|
||||
)
|
||||
expect(core.setFailed).toHaveBeenCalledWith({ status: 400 })
|
||||
|
||||
scope.done()
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('check', () => {
|
||||
beforeAll(() => {
|
||||
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
||||
process.env.GITHUB_RUN_ID = '123'
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
||||
process.env.GITHUB_TOKEN = 'gha-token'
|
||||
process.env.GITHUB_SHA = '123abc'
|
||||
process.env.GITHUB_ACTOR = 'monalisa'
|
||||
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
||||
process.env.GITHUB_ACTION_PATH = 'something'
|
||||
|
||||
jest.spyOn(core, 'setOutput').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
|
||||
jest.spyOn(core, 'setFailed').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
// Mock error/warning/info/debug
|
||||
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||
})
|
||||
|
||||
it('sets output to success when deployment is successful', async () => {
|
||||
process.env.GITHUB_SHA = 'valid-build-version'
|
||||
let repositoryNwo = process.env.GITHUB_REPOSITORY
|
||||
let buildVersion = process.env.GITHUB_SHA
|
||||
|
||||
// mock a successful call to create a deployment
|
||||
axios.post = jest.fn().mockResolvedValue({ status: 200 })
|
||||
|
||||
// mock a completed deployment with status = 'succeed'
|
||||
axios.get = jest.fn().mockResolvedValue({
|
||||
status: 200,
|
||||
data: {
|
||||
status: 'succeed'
|
||||
}
|
||||
})
|
||||
|
||||
// Create the deployment
|
||||
const deployment = new Deployment()
|
||||
core.GetInput = jest.fn(input => {
|
||||
switch (input) {
|
||||
case 'timeout':
|
||||
return 10 * 1000
|
||||
case 'reporting_interval':
|
||||
return 0
|
||||
}
|
||||
})
|
||||
jest.spyOn(core, 'getInput')
|
||||
await deployment.check()
|
||||
|
||||
expect(axios.get).toBeCalledWith(
|
||||
`https://api.github.com/repos/${repositoryNwo}/pages/deployment/status/${buildVersion}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'token '
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
expect(core.setOutput).toBeCalledWith('status', 'succeed')
|
||||
|
||||
expect(core.info).toHaveBeenCalledWith('Reported success!')
|
||||
})
|
||||
})
|
||||
57
src/pre.js
Normal file
57
src/pre.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const core = require('@actions/core')
|
||||
const axios = require('axios')
|
||||
const axiosRetry = require('axios-retry')
|
||||
const retryAttempt = 3
|
||||
|
||||
axiosRetry(axios, {
|
||||
retries: retryAttempt,
|
||||
retryDelay: retryCount => {
|
||||
core.info(`retrying to send pages telemetry with attempt: ${retryCount}`)
|
||||
return retryCount * 1000 // time interval between retries, with 1s, 2s, 3s
|
||||
},
|
||||
|
||||
// retry on error greater than 500
|
||||
retryCondition: error => {
|
||||
return error.response.status >= 500
|
||||
}
|
||||
})
|
||||
|
||||
const {Deployment} = require('./deployment')
|
||||
|
||||
async function emitTelemetry() {
|
||||
// All variables we need from the runtime are set in the Deployment constructor
|
||||
const deployment = new Deployment()
|
||||
const telemetryUrl = `https://api.github.com/repos/${deployment.repositoryNwo}/pages/telemetry`
|
||||
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
|
||||
await axios
|
||||
.post(
|
||||
telemetryUrl,
|
||||
{github_run_id: deployment.workflowRun},
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
Authorization: `Bearer ${deployment.githubToken}`,
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
.catch(err => {
|
||||
if (err.response.status !== 200) {
|
||||
throw new Error(
|
||||
`failed to emit metric with status code: ${err.response.status} after ${retryAttempt} retry attempts`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
await emitTelemetry()
|
||||
} catch (error) {
|
||||
core.error('failed to emit pages build telemetry')
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
module.exports = {emitTelemetry}
|
||||
64
src/pre.test.js
Normal file
64
src/pre.test.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const core = require('@actions/core')
|
||||
const process = require('process')
|
||||
const axios = require('axios')
|
||||
|
||||
const {expect, jest} = require('@jest/globals')
|
||||
|
||||
const {emitTelemetry} = require('./pre')
|
||||
|
||||
describe('emitTelemetry', () => {
|
||||
beforeAll(() => {
|
||||
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
||||
process.env.GITHUB_RUN_ID = '123'
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
||||
process.env.GITHUB_TOKEN = 'gha-token'
|
||||
process.env.GITHUB_SHA = '123abc'
|
||||
process.env.GITHUB_ACTOR = 'monalisa'
|
||||
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
||||
process.env.GITHUB_ACTION_PATH = 'something'
|
||||
|
||||
jest.spyOn(core, 'setOutput').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
|
||||
jest.spyOn(core, 'setFailed').mockImplementation(param => {
|
||||
return param
|
||||
})
|
||||
// Mock error/warning/info/debug
|
||||
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||
})
|
||||
|
||||
it('will send telemetry to github api', done => {
|
||||
process.env.GITHUB_SHA = 'valid-build-version'
|
||||
|
||||
axios.post = jest.fn().mockResolvedValue({
|
||||
status: 200,
|
||||
data: {
|
||||
status: 'succeed'
|
||||
}
|
||||
})
|
||||
|
||||
emitTelemetry()
|
||||
|
||||
expect(axios.post).toBeCalledWith(
|
||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/telemetry',
|
||||
{
|
||||
github_run_id: process.env.GITHUB_RUN_ID
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3+json',
|
||||
Authorization: 'Bearer ',
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
expect(core.setFailed).not.toHaveBeenCalled()
|
||||
done()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user