mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-29 01:14:53 +00:00
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75c1124b14 | ||
|
|
766cde6ce5 | ||
|
|
1352fce070 | ||
|
|
12ecc67b1a | ||
|
|
b388ef8bf2 | ||
|
|
818dc836a0 | ||
|
|
60e36109df | ||
|
|
7098b54017 | ||
|
|
539d415250 | ||
|
|
af51f9ed91 | ||
|
|
6e7a81b68f | ||
|
|
6bbc94d747 | ||
|
|
20ece23417 | ||
|
|
503d9f28e7 | ||
|
|
f8491fe25c | ||
|
|
de75c272ff | ||
|
|
5e811dcf4c | ||
|
|
f14d75a58d | ||
|
|
2727d0f5db | ||
|
|
67de43d94c | ||
|
|
1996917397 | ||
|
|
44d4246912 | ||
|
|
5de668770e | ||
|
|
1c52af2b34 | ||
|
|
c2379ec5e7 | ||
|
|
e7d22decca | ||
|
|
9b78820d58 | ||
|
|
dd23652c5c | ||
|
|
ec456f786c | ||
|
|
b68f047ef0 | ||
|
|
791c72a9c0 | ||
|
|
b45768bc0f | ||
|
|
3c12eff351 | ||
|
|
f5fafd81c2 | ||
|
|
f8578825e2 | ||
|
|
d2d7f752d5 | ||
|
|
ad109d8dbd | ||
|
|
3ed1d6d9a8 | ||
|
|
71efac92ad | ||
|
|
b742641b90 | ||
|
|
e4de7aa8e4 | ||
|
|
84346747a3 | ||
|
|
9113cc7efc | ||
|
|
858592354e | ||
|
|
114f9cc1f8 | ||
|
|
0dfe0f0668 | ||
|
|
c7c77bb21c | ||
|
|
369d1aed92 | ||
|
|
4865e84b02 | ||
|
|
b627026553 | ||
|
|
9bd912c0ca | ||
|
|
ed034ea1c3 | ||
|
|
8f9a38d5e7 | ||
|
|
71b1669225 |
@@ -1,2 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
dist/
|
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"commonjs": true,
|
"commonjs": true,
|
||||||
"es6": true,
|
"es2021": true,
|
||||||
"jest": true,
|
"node": true,
|
||||||
"node": true
|
"jest": true
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
},
|
||||||
|
"plugins": ["github"],
|
||||||
|
"extends": ["eslint:recommended", "prettier", "plugin:github/internal"],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018
|
"ecmaVersion": 12
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"semi": ["error", "never"]
|
"semi": ["error", "never"]
|
||||||
}
|
},
|
||||||
}
|
"ignorePatterns": ["/dist/", "/pre/"]
|
||||||
|
}
|
||||||
|
|||||||
2
.github/CODEOWNERS
vendored
Normal file
2
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Default PR reviewers
|
||||||
|
* @actions/pages
|
||||||
4
.github/release-drafter.yml
vendored
4
.github/release-drafter.yml
vendored
@@ -3,8 +3,10 @@ name-template: 'v$RESOLVED_VERSION'
|
|||||||
tag-template: 'v$RESOLVED_VERSION'
|
tag-template: 'v$RESOLVED_VERSION'
|
||||||
template: |
|
template: |
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
$CHANGES
|
$CHANGES
|
||||||
See details of [all code changes](https://github.com/actions/deploy-pages/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release
|
|
||||||
|
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release.
|
||||||
categories:
|
categories:
|
||||||
- title: '🚀 Features'
|
- title: '🚀 Features'
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
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: Check 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:check
|
||||||
58
.github/workflows/codeql-analysis.yml
vendored
58
.github/workflows/codeql-analysis.yml
vendored
@@ -9,14 +9,14 @@
|
|||||||
# the `language` matrix defined below to confirm you have the correct set of
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
# supported CodeQL languages.
|
# supported CodeQL languages.
|
||||||
#
|
#
|
||||||
name: "CodeQL"
|
name: 'CodeQL'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '40 0 * * 1'
|
- cron: '40 0 * * 1'
|
||||||
|
|
||||||
@@ -32,39 +32,39 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: [ 'javascript' ]
|
language: ['javascript']
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
# By default, queries listed here will override any specified in a config file.
|
# By default, queries listed here will override any specified in a config file.
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
# and modify them (or add more) to build your code if your project
|
# and modify them (or add more) to build your code if your project
|
||||||
# uses a compiled language
|
# uses a compiled language
|
||||||
|
|
||||||
#- run: |
|
#- run: |
|
||||||
# make bootstrap
|
# make bootstrap
|
||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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:
|
||||||
@@ -10,19 +10,21 @@ on:
|
|||||||
|
|
||||||
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
|
||||||
uses: actions/publish-action@v0.1.0
|
uses: actions/publish-action@v0.1.0
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
30
.github/workflows/test.yml
vendored
30
.github/workflows/test.yml
vendored
@@ -9,20 +9,20 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set Node.JS
|
- name: Set Node.JS
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm run test
|
run: npm run test
|
||||||
# Drafts your next Release notes as Pull Requests are merged into "main"
|
# Drafts your next Release notes as Pull Requests are merged into "main"
|
||||||
- uses: release-drafter/release-drafter@v5
|
- uses: release-drafter/release-drafter@v5
|
||||||
if: github.ref_name == 'main'
|
if: github.ref_name == 'main'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
node_modules/
|
# Ignore build artifacts
|
||||||
|
/dist/
|
||||||
|
/pre/
|
||||||
|
|
||||||
|
# Ignore all Markdown files
|
||||||
|
*.md
|
||||||
|
|||||||
@@ -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
|
||||||
16
README.md
16
README.md
@@ -62,6 +62,18 @@ There are a few important considerations to be aware of:
|
|||||||
|
|
||||||
5. If your Pages site is using GitHub Actions as the source, while not required we highly recommend you also [protect your environment][environment-protection] (we do it by default for you)
|
5. If your Pages site is using GitHub Actions as the source, while not required we highly recommend you also [protect your environment][environment-protection] (we do it by default for you)
|
||||||
|
|
||||||
|
# Release instructions
|
||||||
|
|
||||||
|
In order to release a new version of this Action:
|
||||||
|
|
||||||
|
1. Locate the semantic version of the [upcoming release][release-list] (a draft is maintained by the [`draft-release` workflow][draft-release]).
|
||||||
|
|
||||||
|
2. Publish the draft release from the `main` branch with semantic version as the tag name, _with_ the checkbox to publish to the GitHub Marketplace checked. :ballot_box_with_check:
|
||||||
|
|
||||||
|
3. After publishing the release, the [`release` workflow][release] will automatically run to create/update the corresponding the major version tag such as `v1`.
|
||||||
|
|
||||||
|
⚠️ Environment approval is required. Check the [Release workflow run list][release-workflow-runs].
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||||
@@ -71,3 +83,7 @@ The scripts and documentation in this project are released under the [MIT Licens
|
|||||||
[upload-pages-artifact]: https://github.com/actions/upload-pages-artifact
|
[upload-pages-artifact]: https://github.com/actions/upload-pages-artifact
|
||||||
[artifacts]: https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts
|
[artifacts]: https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts
|
||||||
[environment-protection]: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-protection-rules
|
[environment-protection]: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-protection-rules
|
||||||
|
[release-list]: https://github.com/actions/deploy-pages/releases
|
||||||
|
[draft-release]: .github/workflows/draft-release.yml
|
||||||
|
[release]: .github/workflows/release.yml
|
||||||
|
[release-workflow-runs]: https://github.com/actions/deploy-pages/actions/workflows/release.yml
|
||||||
|
|||||||
17
action.yml
17
action.yml
@@ -8,7 +8,10 @@ inputs:
|
|||||||
emit_telemetry:
|
emit_telemetry:
|
||||||
description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
|
description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: 'false'
|
||||||
|
conclusion:
|
||||||
|
description: 'The status of the previous build.'
|
||||||
|
required: false
|
||||||
token:
|
token:
|
||||||
description: 'GitHub token'
|
description: 'GitHub token'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
@@ -16,19 +19,23 @@ inputs:
|
|||||||
timeout:
|
timeout:
|
||||||
description: 'Time in milliseconds after which to timeout and cancel the deployment (default: 10 minutes)'
|
description: 'Time in milliseconds after which to timeout and cancel the deployment (default: 10 minutes)'
|
||||||
required: false
|
required: false
|
||||||
default: "600000"
|
default: '600000'
|
||||||
error_count:
|
error_count:
|
||||||
description: 'Maximum number of status report errors before cancelling a deployment (default: 10)'
|
description: 'Maximum number of status report errors before cancelling a deployment (default: 10)'
|
||||||
required: false
|
required: false
|
||||||
default: "10"
|
default: '10'
|
||||||
reporting_interval:
|
reporting_interval:
|
||||||
description: 'Time in milliseconds between two deployment status report (default: 5 seconds)'
|
description: 'Time in milliseconds between two deployment status report (default: 5 seconds)'
|
||||||
required: false
|
required: false
|
||||||
default: "5000"
|
default: '5000'
|
||||||
artifact_name:
|
artifact_name:
|
||||||
description: 'Name of the artifact to deploy'
|
description: 'Name of the artifact to deploy'
|
||||||
required: false
|
required: false
|
||||||
default: "github-pages"
|
default: 'github-pages'
|
||||||
|
preview:
|
||||||
|
description: 'Is this attempting to deploy a pull request as a GitHub Pages preview site? (NOTE: This feature is only in alpha currently and is not available to the public!)'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
outputs:
|
outputs:
|
||||||
page_url:
|
page_url:
|
||||||
description: 'URL to deployed GitHub Pages'
|
description: 'URL to deployed GitHub Pages'
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = {presets: ['@babel/preset-env']}
|
|
||||||
413
dist/index.js
vendored
413
dist/index.js
vendored
@@ -8177,7 +8177,8 @@ function getRequiredVars() {
|
|||||||
actionsId: process.env.GITHUB_ACTION,
|
actionsId: process.env.GITHUB_ACTION,
|
||||||
githubToken: core.getInput('token'),
|
githubToken: core.getInput('token'),
|
||||||
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
||||||
artifactName: core.getInput('artifact_name') ?? 'github-pages'
|
artifactName: core.getInput('artifact_name') ?? 'github-pages',
|
||||||
|
isPreview: core.getInput('preview') === 'true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8198,8 +8199,6 @@ module.exports = function getContext() {
|
|||||||
/***/ 2877:
|
/***/ 2877:
|
||||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
__nccwpck_require__(4307)
|
|
||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const axios = __nccwpck_require__(6545)
|
const axios = __nccwpck_require__(6545)
|
||||||
|
|
||||||
@@ -8207,184 +8206,231 @@ const axios = __nccwpck_require__(6545)
|
|||||||
const getContext = __nccwpck_require__(1319)
|
const getContext = __nccwpck_require__(1319)
|
||||||
|
|
||||||
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 {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
this.runTimeUrl = context.runTimeUrl
|
this.runTimeUrl = context.runTimeUrl
|
||||||
this.repositoryNwo = context.repositoryNwo
|
this.repositoryNwo = context.repositoryNwo
|
||||||
this.runTimeToken = context.runTimeToken
|
this.runTimeToken = context.runTimeToken
|
||||||
this.buildVersion = context.buildVersion
|
this.buildVersion = context.buildVersion
|
||||||
this.buildActor = context.buildActor
|
this.buildActor = context.buildActor
|
||||||
this.actionsId = context.workflowRun
|
this.actionsId = context.workflowRun
|
||||||
this.githubToken = context.githubToken
|
this.githubToken = context.githubToken
|
||||||
this.workflowRun = context.workflowRun
|
this.workflowRun = context.workflowRun
|
||||||
this.requestedDeployment = false
|
this.requestedDeployment = false
|
||||||
this.deploymentInfo = null
|
this.deploymentInfo = null
|
||||||
this.githubApiUrl = context.githubApiUrl
|
this.githubApiUrl = context.githubApiUrl
|
||||||
this.artifactName = context.artifactName
|
this.artifactName = context.artifactName
|
||||||
}
|
this.isPreview = context.isPreview === true
|
||||||
|
}
|
||||||
|
|
||||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
// by creating a deployment with that artifact
|
// by creating a deployment with that artifact
|
||||||
async create(idToken) {
|
async create(idToken) {
|
||||||
try {
|
try {
|
||||||
core.info(`Actor: ${this.buildActor}`)
|
core.info(`Actor: ${this.buildActor}`)
|
||||||
core.info(`Action ID: ${this.actionsId}`)
|
core.info(`Action ID: ${this.actionsId}`)
|
||||||
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: {
|
||||||
|
Authorization: `Bearer ${this.runTimeToken}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
core.info(JSON.stringify(data))
|
||||||
|
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
||||||
|
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.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
||||||
|
const payload = {
|
||||||
|
artifact_url: artifactUrl,
|
||||||
|
pages_build_version: this.buildVersion,
|
||||||
|
oidc_token: idToken
|
||||||
|
}
|
||||||
|
if (this.isPreview === true) {
|
||||||
|
payload.preview = true
|
||||||
|
}
|
||||||
|
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}`)
|
||||||
|
if (response && response.data) {
|
||||||
|
core.info(JSON.stringify(response.data))
|
||||||
|
this.deploymentInfo = response.data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.info(error.stack)
|
||||||
|
|
||||||
|
// output raw error in debug mode.
|
||||||
|
core.debug(JSON.stringify(error))
|
||||||
|
|
||||||
|
// build customized error message based on server response
|
||||||
|
if (error.response) {
|
||||||
|
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
||||||
|
if (error.response.status == 400) {
|
||||||
|
let message = ''
|
||||||
|
if (error.response.data && error.response.data.message) {
|
||||||
|
message = error.response.data.message
|
||||||
|
} else {
|
||||||
|
message = error.response.data
|
||||||
|
}
|
||||||
|
errorMessage += `Responded with: ${message}`
|
||||||
|
} else if (error.response.status == 403) {
|
||||||
|
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
||||||
|
} else if (error.response.status == 404) {
|
||||||
|
errorMessage += `Ensure GitHub Pages has been enabled.`
|
||||||
|
} 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.`
|
||||||
|
}
|
||||||
|
throw errorMessage
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Poll the deployment endpoint for status
|
||||||
|
async check() {
|
||||||
|
try {
|
||||||
|
const statusUrl =
|
||||||
|
this.deploymentInfo != null
|
||||||
|
? this.deploymentInfo['status_url']
|
||||||
|
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||||
|
let pageUrl = this.deploymentInfo != null ? this.deploymentInfo['page_url'] : ''
|
||||||
|
const previewUrl = this.deploymentInfo != null ? this.deploymentInfo['preview_url'] : ''
|
||||||
|
if (this.isPreview && previewUrl) {
|
||||||
|
pageUrl = previewUrl
|
||||||
|
}
|
||||||
|
core.setOutput('page_url', pageUrl)
|
||||||
|
const timeout = Number(core.getInput('timeout'))
|
||||||
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
|
const maxErrorCount = Number(core.getInput('error_count'))
|
||||||
|
var startTime = Date.now()
|
||||||
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
|
while (true) {
|
||||||
|
// Handle reporting interval
|
||||||
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
var res = await axios.get(statusUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.runTimeToken}`,
|
Authorization: `token ${this.githubToken}`
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
core.info(JSON.stringify(data))
|
|
||||||
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
if (res.data.status == 'succeed') {
|
||||||
if (!artifactRawUrl) {
|
core.info('Reported success!')
|
||||||
throw new Error('No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.')
|
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.setFailed('Deployment failed, try again later.')
|
||||||
|
break
|
||||||
|
} else if (res.data.status == 'deployment_content_failed') {
|
||||||
|
// 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.'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
} else if (errorStatus[res.data.status]) {
|
||||||
|
// A temporary error happened, will query the status again
|
||||||
|
core.info(errorStatus[res.data.status])
|
||||||
|
} else {
|
||||||
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
const payload = {
|
errorCount++
|
||||||
artifact_url: artifactUrl,
|
|
||||||
pages_build_version: this.buildVersion,
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
oidc_token: idToken
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = (errorReportingInterval << 1) | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
core.info(`Creating deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
|
|
||||||
const response = await axios.post(pagesDeployEndpoint, payload, {
|
if (errorCount >= maxErrorCount) {
|
||||||
|
core.info('Too many errors, aborting!')
|
||||||
|
core.setFailed('Failed with status code: ' + res.status)
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle timeout
|
||||||
|
if (Date.now() - startTime >= timeout) {
|
||||||
|
core.info('Timeout reached, aborting!')
|
||||||
|
core.setFailed('Timeout reached, aborting!')
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error)
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
core.info(JSON.stringify(error.response.data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancel() {
|
||||||
|
// Don't attemp to cancel if no deployment was created
|
||||||
|
if (!this.requestedDeployment) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel the deployment
|
||||||
|
try {
|
||||||
|
const pagesCancelDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/cancel/${this.buildVersion}`
|
||||||
|
await axios.put(
|
||||||
|
pagesCancelDeployEndpoint,
|
||||||
|
{},
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
Authorization: `Bearer ${this.githubToken}`,
|
Authorization: `Bearer ${this.githubToken}`,
|
||||||
'Content-type': 'application/json'
|
'Content-type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
|
||||||
this.requestedDeployment = true
|
|
||||||
core.info(`Created deployment for ${this.buildVersion}`)
|
|
||||||
if (response && response.data) {
|
|
||||||
core.info(JSON.stringify(response.data))
|
|
||||||
this.deploymentInfo = response.data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
core.info(error.stack)
|
|
||||||
|
|
||||||
// output raw error in debug mode.
|
|
||||||
core.debug(JSON.stringify(error))
|
|
||||||
|
|
||||||
// build customized error message based on server response
|
|
||||||
if (error.response) {
|
|
||||||
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
|
||||||
if (error.response.status == 400) {
|
|
||||||
let message = ""
|
|
||||||
if (error.response.data && error.response.data.message) {
|
|
||||||
message = error.response.data.message
|
|
||||||
} else {
|
|
||||||
message = error.response.data
|
|
||||||
}
|
|
||||||
errorMessage += `Responded with: ${message}`
|
|
||||||
}
|
|
||||||
else if (error.response.status == 403) {
|
|
||||||
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
|
||||||
} else if (error.response.status == 404) {
|
|
||||||
errorMessage += `Ensure GitHub Pages has been enabled.`
|
|
||||||
}
|
|
||||||
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.`
|
|
||||||
}
|
|
||||||
throw errorMessage
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Poll the deployment endpoint for status
|
|
||||||
async check() {
|
|
||||||
try {
|
|
||||||
const statusUrl = this.deploymentInfo != null ?
|
|
||||||
this.deploymentInfo["status_url"] :
|
|
||||||
`${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
|
||||||
const timeout = Number(core.getInput('timeout'))
|
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
var startTime = Date.now()
|
|
||||||
var errorCount = 0
|
|
||||||
|
|
||||||
// Time in milliseconds between two deployment status report when status errored, default 0.
|
|
||||||
var errorReportingInterval = 0
|
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
|
||||||
while (true) {
|
|
||||||
// Handle reporting interval
|
|
||||||
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
|
||||||
|
|
||||||
// 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.setFailed('Deployment failed, try again later.')
|
|
||||||
break
|
|
||||||
} else if(res.data.status == 'deployment_content_failed') {
|
|
||||||
// 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.')
|
|
||||||
break
|
|
||||||
} else if (errorStatus[res.data.status]) {
|
|
||||||
// A temporary error happened, will query the status again
|
|
||||||
core.info(errorStatus[res.data.status])
|
|
||||||
} else {
|
|
||||||
core.info('Current status: ' + res.data.status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
|
||||||
errorCount++
|
|
||||||
|
|
||||||
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
|
||||||
if (errorReportingInterval < 1000 * 15) {
|
|
||||||
errorReportingInterval = errorReportingInterval << 1 | 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// reset the error reporting interval once get the proper status back.
|
|
||||||
errorReportingInterval = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
if (error.response && error.response.data) {
|
|
||||||
core.info(JSON.stringify(error.response.data))
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
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}
|
}
|
||||||
|
module.exports = { Deployment }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@@ -8409,17 +8455,18 @@ axiosRetry(axios, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const {Deployment} = __nccwpck_require__(2877)
|
const { Deployment } = __nccwpck_require__(2877)
|
||||||
|
|
||||||
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
|
||||||
const deployment = new Deployment()
|
const deployment = new Deployment()
|
||||||
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
||||||
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
|
const conclusion = core.getInput('conclusion') || null
|
||||||
|
core.info(`Sending telemetry for run id ${deployment.workflowRun}: ${conclusion}`)
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
telemetryUrl,
|
telemetryUrl,
|
||||||
{github_run_id: deployment.workflowRun},
|
{ github_run_id: deployment.workflowRun, conclusion },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
@@ -8447,7 +8494,7 @@ async function main() {
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
module.exports = {emitTelemetry}
|
module.exports = { emitTelemetry }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -8613,47 +8660,23 @@ module.exports = require("zlib");
|
|||||||
var __webpack_exports__ = {};
|
var __webpack_exports__ = {};
|
||||||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
(() => {
|
(() => {
|
||||||
__nccwpck_require__(4307)
|
|
||||||
|
|
||||||
// This package assumes a site has already been built and the files exist in the current workspace
|
// 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,
|
// 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.
|
// without the user having to do the tar process themselves.
|
||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
// 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 = __nccwpck_require__(6545)
|
|
||||||
|
|
||||||
const {Deployment} = __nccwpck_require__(2877)
|
const { Deployment } = __nccwpck_require__(2877)
|
||||||
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) {
|
||||||
@@ -8674,8 +8697,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') {
|
||||||
__nccwpck_require__(9557)
|
__nccwpck_require__(9557)
|
||||||
} else {
|
} else {
|
||||||
main()
|
main()
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
transform: {
|
|
||||||
'^.+\\.(js|jsx)$': 'babel-jest'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2704
package-lock.json
generated
2704
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -4,17 +4,11 @@
|
|||||||
"description": "Deploy an actions artifact to GitHub Pages",
|
"description": "Deploy an actions artifact to GitHub Pages",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^0.5.2",
|
|
||||||
"@actions/core": "^1.9.1",
|
"@actions/core": "^1.9.1",
|
||||||
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"regenerator-runtime": "^0.13.9",
|
"axios-retry": "^3.2.4"
|
||||||
"axios-retry": "^3.2.4",
|
|
||||||
"tar": "^6.1.11"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-env": "^7.16.0",
|
|
||||||
"@github/prettier-config": "0.0.4",
|
|
||||||
"@vercel/ncc": "^0.31.1",
|
"@vercel/ncc": "^0.31.1",
|
||||||
"eslint": "^8.2.0",
|
"eslint": "^8.2.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
@@ -24,14 +18,17 @@
|
|||||||
"prettier": "^2.4.1"
|
"prettier": "^2.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint src",
|
"all": "npm run format && npm run lint && npm run prepare && npm run test",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"format:check": "prettier --check .",
|
||||||
|
"lint": "DEBUG=eslint:cli-engine eslint --fix .",
|
||||||
|
"lint:check": "DEBUG=eslint:cli-engine eslint .",
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/paper-spa/deploy-pages.git"
|
"url": "git+https://github.com/actions/deploy-pages.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"GitHub",
|
"GitHub",
|
||||||
@@ -40,7 +37,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/paper-spa/deploy-pages/issues"
|
"url": "https://github.com/actions/deploy-pages/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/paper-spa/deploy-pages#readme"
|
"homepage": "https://github.com/actions/deploy-pages#readme"
|
||||||
}
|
}
|
||||||
|
|||||||
379
pre/index.js
379
pre/index.js
@@ -8177,7 +8177,8 @@ function getRequiredVars() {
|
|||||||
actionsId: process.env.GITHUB_ACTION,
|
actionsId: process.env.GITHUB_ACTION,
|
||||||
githubToken: core.getInput('token'),
|
githubToken: core.getInput('token'),
|
||||||
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
||||||
artifactName: core.getInput('artifact_name') ?? 'github-pages'
|
artifactName: core.getInput('artifact_name') ?? 'github-pages',
|
||||||
|
isPreview: core.getInput('preview') === 'true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8198,8 +8199,6 @@ module.exports = function getContext() {
|
|||||||
/***/ 2877:
|
/***/ 2877:
|
||||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
__nccwpck_require__(4307)
|
|
||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const axios = __nccwpck_require__(6545)
|
const axios = __nccwpck_require__(6545)
|
||||||
|
|
||||||
@@ -8207,184 +8206,231 @@ const axios = __nccwpck_require__(6545)
|
|||||||
const getContext = __nccwpck_require__(1319)
|
const getContext = __nccwpck_require__(1319)
|
||||||
|
|
||||||
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 {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
this.runTimeUrl = context.runTimeUrl
|
this.runTimeUrl = context.runTimeUrl
|
||||||
this.repositoryNwo = context.repositoryNwo
|
this.repositoryNwo = context.repositoryNwo
|
||||||
this.runTimeToken = context.runTimeToken
|
this.runTimeToken = context.runTimeToken
|
||||||
this.buildVersion = context.buildVersion
|
this.buildVersion = context.buildVersion
|
||||||
this.buildActor = context.buildActor
|
this.buildActor = context.buildActor
|
||||||
this.actionsId = context.workflowRun
|
this.actionsId = context.workflowRun
|
||||||
this.githubToken = context.githubToken
|
this.githubToken = context.githubToken
|
||||||
this.workflowRun = context.workflowRun
|
this.workflowRun = context.workflowRun
|
||||||
this.requestedDeployment = false
|
this.requestedDeployment = false
|
||||||
this.deploymentInfo = null
|
this.deploymentInfo = null
|
||||||
this.githubApiUrl = context.githubApiUrl
|
this.githubApiUrl = context.githubApiUrl
|
||||||
this.artifactName = context.artifactName
|
this.artifactName = context.artifactName
|
||||||
}
|
this.isPreview = context.isPreview === true
|
||||||
|
}
|
||||||
|
|
||||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
// by creating a deployment with that artifact
|
// by creating a deployment with that artifact
|
||||||
async create(idToken) {
|
async create(idToken) {
|
||||||
try {
|
try {
|
||||||
core.info(`Actor: ${this.buildActor}`)
|
core.info(`Actor: ${this.buildActor}`)
|
||||||
core.info(`Action ID: ${this.actionsId}`)
|
core.info(`Action ID: ${this.actionsId}`)
|
||||||
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: {
|
||||||
|
Authorization: `Bearer ${this.runTimeToken}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
core.info(JSON.stringify(data))
|
||||||
|
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
||||||
|
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.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
||||||
|
const payload = {
|
||||||
|
artifact_url: artifactUrl,
|
||||||
|
pages_build_version: this.buildVersion,
|
||||||
|
oidc_token: idToken
|
||||||
|
}
|
||||||
|
if (this.isPreview === true) {
|
||||||
|
payload.preview = true
|
||||||
|
}
|
||||||
|
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}`)
|
||||||
|
if (response && response.data) {
|
||||||
|
core.info(JSON.stringify(response.data))
|
||||||
|
this.deploymentInfo = response.data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.info(error.stack)
|
||||||
|
|
||||||
|
// output raw error in debug mode.
|
||||||
|
core.debug(JSON.stringify(error))
|
||||||
|
|
||||||
|
// build customized error message based on server response
|
||||||
|
if (error.response) {
|
||||||
|
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
||||||
|
if (error.response.status == 400) {
|
||||||
|
let message = ''
|
||||||
|
if (error.response.data && error.response.data.message) {
|
||||||
|
message = error.response.data.message
|
||||||
|
} else {
|
||||||
|
message = error.response.data
|
||||||
|
}
|
||||||
|
errorMessage += `Responded with: ${message}`
|
||||||
|
} else if (error.response.status == 403) {
|
||||||
|
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
||||||
|
} else if (error.response.status == 404) {
|
||||||
|
errorMessage += `Ensure GitHub Pages has been enabled.`
|
||||||
|
} 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.`
|
||||||
|
}
|
||||||
|
throw errorMessage
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Poll the deployment endpoint for status
|
||||||
|
async check() {
|
||||||
|
try {
|
||||||
|
const statusUrl =
|
||||||
|
this.deploymentInfo != null
|
||||||
|
? this.deploymentInfo['status_url']
|
||||||
|
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||||
|
let pageUrl = this.deploymentInfo != null ? this.deploymentInfo['page_url'] : ''
|
||||||
|
const previewUrl = this.deploymentInfo != null ? this.deploymentInfo['preview_url'] : ''
|
||||||
|
if (this.isPreview && previewUrl) {
|
||||||
|
pageUrl = previewUrl
|
||||||
|
}
|
||||||
|
core.setOutput('page_url', pageUrl)
|
||||||
|
const timeout = Number(core.getInput('timeout'))
|
||||||
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
|
const maxErrorCount = Number(core.getInput('error_count'))
|
||||||
|
var startTime = Date.now()
|
||||||
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
|
while (true) {
|
||||||
|
// Handle reporting interval
|
||||||
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
var res = await axios.get(statusUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.runTimeToken}`,
|
Authorization: `token ${this.githubToken}`
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
core.info(JSON.stringify(data))
|
|
||||||
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
if (res.data.status == 'succeed') {
|
||||||
if (!artifactRawUrl) {
|
core.info('Reported success!')
|
||||||
throw new Error('No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.')
|
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.setFailed('Deployment failed, try again later.')
|
||||||
|
break
|
||||||
|
} else if (res.data.status == 'deployment_content_failed') {
|
||||||
|
// 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.'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
} else if (errorStatus[res.data.status]) {
|
||||||
|
// A temporary error happened, will query the status again
|
||||||
|
core.info(errorStatus[res.data.status])
|
||||||
|
} else {
|
||||||
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
const payload = {
|
errorCount++
|
||||||
artifact_url: artifactUrl,
|
|
||||||
pages_build_version: this.buildVersion,
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
oidc_token: idToken
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = (errorReportingInterval << 1) | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
core.info(`Creating deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
|
|
||||||
const response = await axios.post(pagesDeployEndpoint, payload, {
|
if (errorCount >= maxErrorCount) {
|
||||||
|
core.info('Too many errors, aborting!')
|
||||||
|
core.setFailed('Failed with status code: ' + res.status)
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle timeout
|
||||||
|
if (Date.now() - startTime >= timeout) {
|
||||||
|
core.info('Timeout reached, aborting!')
|
||||||
|
core.setFailed('Timeout reached, aborting!')
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error)
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
core.info(JSON.stringify(error.response.data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancel() {
|
||||||
|
// Don't attemp to cancel if no deployment was created
|
||||||
|
if (!this.requestedDeployment) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel the deployment
|
||||||
|
try {
|
||||||
|
const pagesCancelDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/cancel/${this.buildVersion}`
|
||||||
|
await axios.put(
|
||||||
|
pagesCancelDeployEndpoint,
|
||||||
|
{},
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
Authorization: `Bearer ${this.githubToken}`,
|
Authorization: `Bearer ${this.githubToken}`,
|
||||||
'Content-type': 'application/json'
|
'Content-type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
|
||||||
this.requestedDeployment = true
|
|
||||||
core.info(`Created deployment for ${this.buildVersion}`)
|
|
||||||
if (response && response.data) {
|
|
||||||
core.info(JSON.stringify(response.data))
|
|
||||||
this.deploymentInfo = response.data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
core.info(error.stack)
|
|
||||||
|
|
||||||
// output raw error in debug mode.
|
|
||||||
core.debug(JSON.stringify(error))
|
|
||||||
|
|
||||||
// build customized error message based on server response
|
|
||||||
if (error.response) {
|
|
||||||
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
|
||||||
if (error.response.status == 400) {
|
|
||||||
let message = ""
|
|
||||||
if (error.response.data && error.response.data.message) {
|
|
||||||
message = error.response.data.message
|
|
||||||
} else {
|
|
||||||
message = error.response.data
|
|
||||||
}
|
|
||||||
errorMessage += `Responded with: ${message}`
|
|
||||||
}
|
|
||||||
else if (error.response.status == 403) {
|
|
||||||
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
|
||||||
} else if (error.response.status == 404) {
|
|
||||||
errorMessage += `Ensure GitHub Pages has been enabled.`
|
|
||||||
}
|
|
||||||
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.`
|
|
||||||
}
|
|
||||||
throw errorMessage
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Poll the deployment endpoint for status
|
|
||||||
async check() {
|
|
||||||
try {
|
|
||||||
const statusUrl = this.deploymentInfo != null ?
|
|
||||||
this.deploymentInfo["status_url"] :
|
|
||||||
`${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
|
||||||
const timeout = Number(core.getInput('timeout'))
|
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
var startTime = Date.now()
|
|
||||||
var errorCount = 0
|
|
||||||
|
|
||||||
// Time in milliseconds between two deployment status report when status errored, default 0.
|
|
||||||
var errorReportingInterval = 0
|
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
|
||||||
while (true) {
|
|
||||||
// Handle reporting interval
|
|
||||||
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
|
||||||
|
|
||||||
// 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.setFailed('Deployment failed, try again later.')
|
|
||||||
break
|
|
||||||
} else if(res.data.status == 'deployment_content_failed') {
|
|
||||||
// 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.')
|
|
||||||
break
|
|
||||||
} else if (errorStatus[res.data.status]) {
|
|
||||||
// A temporary error happened, will query the status again
|
|
||||||
core.info(errorStatus[res.data.status])
|
|
||||||
} else {
|
|
||||||
core.info('Current status: ' + res.data.status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
|
||||||
errorCount++
|
|
||||||
|
|
||||||
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
|
||||||
if (errorReportingInterval < 1000 * 15) {
|
|
||||||
errorReportingInterval = errorReportingInterval << 1 | 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// reset the error reporting interval once get the proper status back.
|
|
||||||
errorReportingInterval = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
if (error.response && error.response.data) {
|
|
||||||
core.info(JSON.stringify(error.response.data))
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
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}
|
}
|
||||||
|
module.exports = { Deployment }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@@ -8409,17 +8455,18 @@ axiosRetry(axios, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const {Deployment} = __nccwpck_require__(2877)
|
const { Deployment } = __nccwpck_require__(2877)
|
||||||
|
|
||||||
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
|
||||||
const deployment = new Deployment()
|
const deployment = new Deployment()
|
||||||
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
||||||
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
|
const conclusion = core.getInput('conclusion') || null
|
||||||
|
core.info(`Sending telemetry for run id ${deployment.workflowRun}: ${conclusion}`)
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
telemetryUrl,
|
telemetryUrl,
|
||||||
{github_run_id: deployment.workflowRun},
|
{ github_run_id: deployment.workflowRun, conclusion },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
@@ -8447,7 +8494,7 @@ async function main() {
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
module.exports = {emitTelemetry}
|
module.exports = { emitTelemetry }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -12,7 +12,8 @@ function getRequiredVars() {
|
|||||||
actionsId: process.env.GITHUB_ACTION,
|
actionsId: process.env.GITHUB_ACTION,
|
||||||
githubToken: core.getInput('token'),
|
githubToken: core.getInput('token'),
|
||||||
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
|
||||||
artifactName: core.getInput('artifact_name') ?? 'github-pages'
|
artifactName: core.getInput('artifact_name') ?? 'github-pages',
|
||||||
|
isPreview: core.getInput('preview') === 'true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
require('regenerator-runtime/runtime')
|
|
||||||
|
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
|
|
||||||
@@ -7,181 +5,227 @@ 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 {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
this.runTimeUrl = context.runTimeUrl
|
this.runTimeUrl = context.runTimeUrl
|
||||||
this.repositoryNwo = context.repositoryNwo
|
this.repositoryNwo = context.repositoryNwo
|
||||||
this.runTimeToken = context.runTimeToken
|
this.runTimeToken = context.runTimeToken
|
||||||
this.buildVersion = context.buildVersion
|
this.buildVersion = context.buildVersion
|
||||||
this.buildActor = context.buildActor
|
this.buildActor = context.buildActor
|
||||||
this.actionsId = context.workflowRun
|
this.actionsId = context.workflowRun
|
||||||
this.githubToken = context.githubToken
|
this.githubToken = context.githubToken
|
||||||
this.workflowRun = context.workflowRun
|
this.workflowRun = context.workflowRun
|
||||||
this.requestedDeployment = false
|
this.requestedDeployment = false
|
||||||
this.deploymentInfo = null
|
this.deploymentInfo = null
|
||||||
this.githubApiUrl = context.githubApiUrl
|
this.githubApiUrl = context.githubApiUrl
|
||||||
this.artifactName = context.artifactName
|
this.artifactName = context.artifactName
|
||||||
}
|
this.isPreview = context.isPreview === true
|
||||||
|
}
|
||||||
|
|
||||||
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
// by creating a deployment with that artifact
|
// by creating a deployment with that artifact
|
||||||
async create(idToken) {
|
async create(idToken) {
|
||||||
try {
|
try {
|
||||||
core.info(`Actor: ${this.buildActor}`)
|
core.info(`Actor: ${this.buildActor}`)
|
||||||
core.info(`Action ID: ${this.actionsId}`)
|
core.info(`Action ID: ${this.actionsId}`)
|
||||||
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: {
|
||||||
|
Authorization: `Bearer ${this.runTimeToken}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
core.info(JSON.stringify(data))
|
||||||
|
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
||||||
|
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.'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
||||||
|
const payload = {
|
||||||
|
artifact_url: artifactUrl,
|
||||||
|
pages_build_version: this.buildVersion,
|
||||||
|
oidc_token: idToken
|
||||||
|
}
|
||||||
|
if (this.isPreview === true) {
|
||||||
|
payload.preview = true
|
||||||
|
}
|
||||||
|
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}`)
|
||||||
|
if (response && response.data) {
|
||||||
|
core.info(JSON.stringify(response.data))
|
||||||
|
this.deploymentInfo = response.data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.info(error.stack)
|
||||||
|
|
||||||
|
// output raw error in debug mode.
|
||||||
|
core.debug(JSON.stringify(error))
|
||||||
|
|
||||||
|
// build customized error message based on server response
|
||||||
|
if (error.response) {
|
||||||
|
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
||||||
|
if (error.response.status == 400) {
|
||||||
|
let message = ''
|
||||||
|
if (error.response.data && error.response.data.message) {
|
||||||
|
message = error.response.data.message
|
||||||
|
} else {
|
||||||
|
message = error.response.data
|
||||||
|
}
|
||||||
|
errorMessage += `Responded with: ${message}`
|
||||||
|
} else if (error.response.status == 403) {
|
||||||
|
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
||||||
|
} else if (error.response.status == 404) {
|
||||||
|
errorMessage += `Ensure GitHub Pages has been enabled.`
|
||||||
|
} 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.`
|
||||||
|
}
|
||||||
|
throw errorMessage
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Poll the deployment endpoint for status
|
||||||
|
async check() {
|
||||||
|
try {
|
||||||
|
const statusUrl =
|
||||||
|
this.deploymentInfo != null
|
||||||
|
? this.deploymentInfo['status_url']
|
||||||
|
: `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${this.buildVersion}`
|
||||||
|
let pageUrl = this.deploymentInfo != null ? this.deploymentInfo['page_url'] : ''
|
||||||
|
const previewUrl = this.deploymentInfo != null ? this.deploymentInfo['preview_url'] : ''
|
||||||
|
if (this.isPreview && previewUrl) {
|
||||||
|
pageUrl = previewUrl
|
||||||
|
}
|
||||||
|
core.setOutput('page_url', pageUrl)
|
||||||
|
const timeout = Number(core.getInput('timeout'))
|
||||||
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
|
const maxErrorCount = Number(core.getInput('error_count'))
|
||||||
|
var startTime = Date.now()
|
||||||
|
var errorCount = 0
|
||||||
|
|
||||||
|
// Time in milliseconds between two deployment status report when status errored, default 0.
|
||||||
|
var errorReportingInterval = 0
|
||||||
|
|
||||||
|
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
||||||
|
while (true) {
|
||||||
|
// Handle reporting interval
|
||||||
|
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
var res = await axios.get(statusUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${this.runTimeToken}`,
|
Authorization: `token ${this.githubToken}`
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
core.info(JSON.stringify(data))
|
|
||||||
const artifactRawUrl = data?.value?.find(artifact => artifact.name === this.artifactName)?.url
|
if (res.data.status == 'succeed') {
|
||||||
if (!artifactRawUrl) {
|
core.info('Reported success!')
|
||||||
throw new Error('No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.')
|
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.setFailed('Deployment failed, try again later.')
|
||||||
|
break
|
||||||
|
} else if (res.data.status == 'deployment_content_failed') {
|
||||||
|
// 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.'
|
||||||
|
)
|
||||||
|
break
|
||||||
|
} else if (errorStatus[res.data.status]) {
|
||||||
|
// A temporary error happened, will query the status again
|
||||||
|
core.info(errorStatus[res.data.status])
|
||||||
|
} else {
|
||||||
|
core.info('Current status: ' + res.data.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
const artifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
||||||
const payload = {
|
errorCount++
|
||||||
artifact_url: artifactUrl,
|
|
||||||
pages_build_version: this.buildVersion,
|
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
||||||
oidc_token: idToken
|
if (errorReportingInterval < 1000 * 15) {
|
||||||
|
errorReportingInterval = (errorReportingInterval << 1) | 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// reset the error reporting interval once get the proper status back.
|
||||||
|
errorReportingInterval = 0
|
||||||
}
|
}
|
||||||
core.info(`Creating deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
|
|
||||||
const response = await axios.post(pagesDeployEndpoint, payload, {
|
if (errorCount >= maxErrorCount) {
|
||||||
|
core.info('Too many errors, aborting!')
|
||||||
|
core.setFailed('Failed with status code: ' + res.status)
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle timeout
|
||||||
|
if (Date.now() - startTime >= timeout) {
|
||||||
|
core.info('Timeout reached, aborting!')
|
||||||
|
core.setFailed('Timeout reached, aborting!')
|
||||||
|
|
||||||
|
// Explicitly cancel the deployment
|
||||||
|
await this.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error)
|
||||||
|
if (error.response && error.response.data) {
|
||||||
|
core.info(JSON.stringify(error.response.data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async cancel() {
|
||||||
|
// Don't attemp to cancel if no deployment was created
|
||||||
|
if (!this.requestedDeployment) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel the deployment
|
||||||
|
try {
|
||||||
|
const pagesCancelDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/cancel/${this.buildVersion}`
|
||||||
|
await axios.put(
|
||||||
|
pagesCancelDeployEndpoint,
|
||||||
|
{},
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
Authorization: `Bearer ${this.githubToken}`,
|
Authorization: `Bearer ${this.githubToken}`,
|
||||||
'Content-type': 'application/json'
|
'Content-type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
|
||||||
this.requestedDeployment = true
|
|
||||||
core.info(`Created deployment for ${this.buildVersion}`)
|
|
||||||
if (response && response.data) {
|
|
||||||
core.info(JSON.stringify(response.data))
|
|
||||||
this.deploymentInfo = response.data
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
core.info(error.stack)
|
|
||||||
|
|
||||||
// output raw error in debug mode.
|
|
||||||
core.debug(JSON.stringify(error))
|
|
||||||
|
|
||||||
// build customized error message based on server response
|
|
||||||
if (error.response) {
|
|
||||||
let errorMessage = `Failed to create deployment (status: ${error.response.status}) with build version ${this.buildVersion}. `
|
|
||||||
if (error.response.status == 400) {
|
|
||||||
let message = ""
|
|
||||||
if (error.response.data && error.response.data.message) {
|
|
||||||
message = error.response.data.message
|
|
||||||
} else {
|
|
||||||
message = error.response.data
|
|
||||||
}
|
|
||||||
errorMessage += `Responded with: ${message}`
|
|
||||||
}
|
|
||||||
else if (error.response.status == 403) {
|
|
||||||
errorMessage += `Ensure GITHUB_TOKEN has permission "pages: write".`
|
|
||||||
} else if (error.response.status == 404) {
|
|
||||||
errorMessage += `Ensure GitHub Pages has been enabled.`
|
|
||||||
}
|
|
||||||
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.`
|
|
||||||
}
|
|
||||||
throw errorMessage
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Poll the deployment endpoint for status
|
|
||||||
async check() {
|
|
||||||
try {
|
|
||||||
const statusUrl = this.deploymentInfo != null ?
|
|
||||||
this.deploymentInfo["status_url"] :
|
|
||||||
`${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
|
|
||||||
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
|
|
||||||
const timeout = Number(core.getInput('timeout'))
|
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
var startTime = Date.now()
|
|
||||||
var errorCount = 0
|
|
||||||
|
|
||||||
// Time in milliseconds between two deployment status report when status errored, default 0.
|
|
||||||
var errorReportingInterval = 0
|
|
||||||
|
|
||||||
/*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
|
|
||||||
while (true) {
|
|
||||||
// Handle reporting interval
|
|
||||||
await new Promise(r => setTimeout(r, reportingInterval + errorReportingInterval))
|
|
||||||
|
|
||||||
// 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.setFailed('Deployment failed, try again later.')
|
|
||||||
break
|
|
||||||
} else if(res.data.status == 'deployment_content_failed') {
|
|
||||||
// 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.')
|
|
||||||
break
|
|
||||||
} else if (errorStatus[res.data.status]) {
|
|
||||||
// A temporary error happened, will query the status again
|
|
||||||
core.info(errorStatus[res.data.status])
|
|
||||||
} else {
|
|
||||||
core.info('Current status: ' + res.data.status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.status != 200 || !!errorStatus[res.data.status]) {
|
|
||||||
errorCount++
|
|
||||||
|
|
||||||
// set the Maximum error reporting interval greater than 15 sec but below 30 sec.
|
|
||||||
if (errorReportingInterval < 1000 * 15) {
|
|
||||||
errorReportingInterval = errorReportingInterval << 1 | 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// reset the error reporting interval once get the proper status back.
|
|
||||||
errorReportingInterval = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
if (error.response && error.response.data) {
|
|
||||||
core.info(JSON.stringify(error.response.data))
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
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}
|
}
|
||||||
|
module.exports = { Deployment }
|
||||||
|
|||||||
34
src/index.js
34
src/index.js
@@ -1,44 +1,20 @@
|
|||||||
require('regenerator-runtime/runtime')
|
|
||||||
|
|
||||||
// This package assumes a site has already been built and the files exist in the current workspace
|
// 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,
|
// 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.
|
// without the user having to do the tar process themselves.
|
||||||
|
|
||||||
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 +35,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()
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ const path = require('path')
|
|||||||
const nock = require('nock')
|
const nock = require('nock')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
|
|
||||||
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(() => {
|
||||||
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
||||||
process.env.GITHUB_RUN_ID = '123'
|
process.env.GITHUB_RUN_ID = '123'
|
||||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
||||||
process.env.GITHUB_TOKEN = 'gha-token'
|
process.env.GITHUB_TOKEN = 'gha-token'
|
||||||
process.env.GITHUB_SHA = '123abc'
|
process.env.GITHUB_SHA = '123abc'
|
||||||
process.env.GITHUB_ACTOR = 'monalisa'
|
process.env.GITHUB_ACTOR = 'monalisa'
|
||||||
@@ -22,6 +20,11 @@ describe('with all environment variables set', () => {
|
|||||||
process.env.GITHUB_ACTION_PATH = 'something'
|
process.env.GITHUB_ACTION_PATH = 'something'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Remove mock for `core.getInput('preview')`
|
||||||
|
delete process.env.INPUT_PREVIEW
|
||||||
|
})
|
||||||
|
|
||||||
it('Executes cleanly', done => {
|
it('Executes cleanly', done => {
|
||||||
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) => {
|
||||||
@@ -35,8 +38,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()
|
||||||
@@ -49,7 +52,7 @@ describe('create', () => {
|
|||||||
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
||||||
process.env.GITHUB_RUN_ID = '123'
|
process.env.GITHUB_RUN_ID = '123'
|
||||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
||||||
process.env.GITHUB_TOKEN = 'gha-token'
|
process.env.GITHUB_TOKEN = 'gha-token'
|
||||||
process.env.GITHUB_SHA = '123abc'
|
process.env.GITHUB_SHA = '123abc'
|
||||||
process.env.GITHUB_ACTOR = 'monalisa'
|
process.env.GITHUB_ACTOR = 'monalisa'
|
||||||
@@ -61,6 +64,8 @@ describe('create', () => {
|
|||||||
return 'github-pages'
|
return 'github-pages'
|
||||||
case 'token':
|
case 'token':
|
||||||
return process.env.GITHUB_TOKEN
|
return process.env.GITHUB_TOKEN
|
||||||
|
default:
|
||||||
|
return process.env[`INPUT_${param.toUpperCase()}`] || ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -80,10 +85,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')
|
||||||
@@ -93,7 +104,7 @@ describe('create', () => {
|
|||||||
await deployment.create(fakeJwt)
|
await deployment.create(fakeJwt)
|
||||||
|
|
||||||
expect(axios.post).toBeCalledWith(
|
expect(axios.post).toBeCalledWith(
|
||||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/deployment',
|
'https://api.github.com/repos/actions/is-awesome/pages/deployment',
|
||||||
{
|
{
|
||||||
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
|
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
|
||||||
pages_build_version: 'valid-build-version',
|
pages_build_version: 'valid-build-version',
|
||||||
@@ -109,10 +120,54 @@ 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()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can successfully create a preview 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://another-artifact.com', name: 'another-artifact' },
|
||||||
|
{ url: 'https://fake-artifact.com', name: 'github-pages' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
|
||||||
|
axios.post = jest.fn().mockResolvedValue('test')
|
||||||
|
|
||||||
|
// Return `"true"` for `core.getInput("preview")`
|
||||||
|
process.env.INPUT_PREVIEW = 'true'
|
||||||
|
|
||||||
|
// Create the deployment
|
||||||
|
const deployment = new Deployment()
|
||||||
|
await deployment.create(fakeJwt)
|
||||||
|
|
||||||
|
expect(axios.post).toBeCalledWith(
|
||||||
|
'https://api.github.com/repos/actions/is-awesome/pages/deployment',
|
||||||
|
{
|
||||||
|
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
|
||||||
|
pages_build_version: 'valid-build-version',
|
||||||
|
oidc_token: fakeJwt,
|
||||||
|
preview: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/vnd.github.v3+json',
|
||||||
|
Authorization: `Bearer gha-token`,
|
||||||
|
'Content-type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
expect(core.setFailed).not.toHaveBeenCalled()
|
||||||
|
expect(core.info).toHaveBeenCalledWith('Created deployment for valid-build-version')
|
||||||
|
|
||||||
scope.done()
|
scope.done()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -131,9 +186,8 @@ 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/actions/is-awesome/pages/deployment',
|
||||||
{
|
{
|
||||||
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
|
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
|
||||||
pages_build_version: 'invalid-build-version'
|
pages_build_version: 'invalid-build-version'
|
||||||
@@ -147,15 +201,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', () => {
|
||||||
@@ -163,7 +214,7 @@ describe('check', () => {
|
|||||||
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
|
||||||
process.env.GITHUB_RUN_ID = '123'
|
process.env.GITHUB_RUN_ID = '123'
|
||||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
||||||
process.env.GITHUB_TOKEN = 'gha-token'
|
process.env.GITHUB_TOKEN = 'gha-token'
|
||||||
process.env.GITHUB_SHA = '123abc'
|
process.env.GITHUB_SHA = '123abc'
|
||||||
process.env.GITHUB_ACTOR = 'monalisa'
|
process.env.GITHUB_ACTOR = 'monalisa'
|
||||||
|
|||||||
@@ -16,17 +16,18 @@ 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
|
||||||
const deployment = new Deployment()
|
const deployment = new Deployment()
|
||||||
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
|
||||||
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
|
const conclusion = core.getInput('conclusion') || null
|
||||||
|
core.info(`Sending telemetry for run id ${deployment.workflowRun}: ${conclusion}`)
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
telemetryUrl,
|
telemetryUrl,
|
||||||
{github_run_id: deployment.workflowRun},
|
{ github_run_id: deployment.workflowRun, conclusion },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
@@ -54,4 +55,4 @@ async function main() {
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
module.exports = {emitTelemetry}
|
module.exports = { emitTelemetry }
|
||||||
|
|||||||
@@ -2,21 +2,20 @@ 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 { emitTelemetry } = require('./pre')
|
||||||
|
|
||||||
const {emitTelemetry} = require('./pre')
|
|
||||||
|
|
||||||
describe('emitTelemetry', () => {
|
describe('emitTelemetry', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
process.env.ACTIONS_RUNTIME_URL = 'my-url'
|
||||||
process.env.GITHUB_RUN_ID = '123'
|
process.env.GITHUB_RUN_ID = '123'
|
||||||
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||||
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
|
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
||||||
process.env.GITHUB_TOKEN = 'gha-token'
|
process.env.GITHUB_TOKEN = 'gha-token'
|
||||||
process.env.GITHUB_SHA = '123abc'
|
process.env.GITHUB_SHA = '123abc'
|
||||||
process.env.GITHUB_ACTOR = 'monalisa'
|
process.env.GITHUB_ACTOR = 'monalisa'
|
||||||
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
process.env.GITHUB_ACTION = '__monalisa/octocat'
|
||||||
process.env.GITHUB_ACTION_PATH = 'something'
|
process.env.GITHUB_ACTION_PATH = 'something'
|
||||||
|
process.env.INPUT_CONCLUSION = 'success'
|
||||||
|
|
||||||
jest.spyOn(core, 'setOutput').mockImplementation(param => {
|
jest.spyOn(core, 'setOutput').mockImplementation(param => {
|
||||||
return param
|
return param
|
||||||
@@ -45,9 +44,10 @@ describe('emitTelemetry', () => {
|
|||||||
emitTelemetry()
|
emitTelemetry()
|
||||||
|
|
||||||
expect(axios.post).toBeCalledWith(
|
expect(axios.post).toBeCalledWith(
|
||||||
'https://api.github.com/repos/paper-spa/is-awesome/pages/telemetry',
|
'https://api.github.com/repos/actions/is-awesome/pages/telemetry',
|
||||||
{
|
{
|
||||||
github_run_id: process.env.GITHUB_RUN_ID
|
github_run_id: process.env.GITHUB_RUN_ID,
|
||||||
|
conclusion: 'success'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user