Compare commits

...

133 Commits

Author SHA1 Message Date
James M. Greene
75c1124b14 Merge pull request #67 from actions/release-process-updates
Update release process in README
2022-09-26 15:45:28 -05:00
James M. Greene
766cde6ce5 Merge branch 'main' into release-process-updates 2022-09-26 15:43:11 -05:00
James M. Greene
1352fce070 Merge pull request #65 from actions/unused-deps
Clean up some unused dependencies
2022-09-26 15:37:52 -05:00
James M. Greene
12ecc67b1a Remove unnecessary Jest config 2022-09-26 15:30:15 -05:00
James M. Greene
b388ef8bf2 Remove unnecessary first-party use of Regenerator 2022-09-26 14:47:48 -05:00
James M. Greene
818dc836a0 Merge branch 'main' into unused-deps 2022-09-26 14:34:08 -05:00
James M. Greene
60e36109df Merge pull request #64 from actions/eslint-roller
Update ESLint config and expand usage
2022-09-26 14:12:25 -05:00
James M. Greene
7098b54017 Merge branch 'main' into eslint-roller 2022-09-26 14:10:15 -05:00
James M. Greene
539d415250 Merge pull request #63 from actions/i-feel-prettier
Expand Prettier usage
2022-09-26 14:08:33 -05:00
James M. Greene
af51f9ed91 Update release process in README 2022-09-19 10:53:48 -05:00
James M. Greene
6e7a81b68f Revise linter Actions workflow 2022-09-16 23:16:38 -05:00
James M. Greene
6bbc94d747 Remove unused deps related to Babel 2022-09-16 23:14:27 -05:00
James M. Greene
20ece23417 Remove unused packages 2022-09-16 23:10:54 -05:00
James M. Greene
503d9f28e7 Remove redundant require for global variables 2022-09-16 23:05:43 -05:00
James M. Greene
f8491fe25c Enhance ESLint configuration 2022-09-16 22:59:17 -05:00
James M. Greene
de75c272ff Expand ESLint usage and add check script 2022-09-16 22:52:58 -05:00
James M. Greene
5e811dcf4c Sort scripts alphabetically 2022-09-16 22:52:36 -05:00
James M. Greene
f14d75a58d Reformat all the things 2022-09-16 22:39:00 -05:00
James M. Greene
2727d0f5db Reorder dependencies alphabetically 2022-09-16 22:37:54 -05:00
James M. Greene
67de43d94c Remove unused dependency 2022-09-16 22:37:33 -05:00
James M. Greene
1996917397 Expand Prettier coverage 2022-09-16 22:36:35 -05:00
Jess Bees
44d4246912 Merge pull request #62 from actions/pages/get-build-conclusion
Add optional 'conclusion' argument to emitTelemetry
2022-09-16 09:33:36 -04:00
Jess Bees
5de668770e Gotta update npm deps to accurately compile it 2022-09-15 13:05:09 -04:00
Jess Bees
1c52af2b34 Add optional 'conclusion' argument to emitTelemetry
If present, will include the value of `conclusion` with the telemetry
POST body (gh/gh needs a separate PR to recognize this)
2022-09-15 12:14:23 -04:00
James M. Greene
c2379ec5e7 Merge pull request #61 from actions/upstream-preview-alpha
Add support for preview deployments internal alpha experiment 🧪
2022-09-13 19:58:43 -05:00
James M. Greene
e7d22decca Remove internal debugging from @actions/core 2022-09-09 18:54:00 -05:00
James M. Greene
9b78820d58 Update distributables 2022-09-09 18:51:52 -05:00
James M. Greene
dd23652c5c Adhere to Prettier formatting 2022-09-09 18:51:35 -05:00
James M. Greene
ec456f786c Correct outdated reference 2022-09-09 18:50:08 -05:00
James M. Greene
b68f047ef0 Merge branch 'main' into upstream-preview-alpha 2022-09-09 18:49:17 -05:00
James M. Greene
791c72a9c0 Merge pull request #60 from actions/yaml-consistency
Use single quotes in Action metadata for consistency
2022-09-09 18:48:39 -05:00
James M. Greene
b45768bc0f Merge branch 'main' into yaml-consistency 2022-09-09 18:47:11 -05:00
James M. Greene
3c12eff351 Merge pull request #59 from actions/fix-org-refs
Correct organization references
2022-09-09 18:46:55 -05:00
James M. Greene
f5fafd81c2 Remove '.only' from the new unit test 2022-09-09 18:46:36 -05:00
James M. Greene
f8578825e2 Update distributables 2022-09-09 18:44:20 -05:00
James M. Greene
d2d7f752d5 Add support for preview deployments 2022-09-09 18:44:03 -05:00
James M. Greene
ad109d8dbd Add failing test 2022-09-09 18:29:17 -05:00
James M. Greene
3ed1d6d9a8 Use single quotes in Action metadata for consistency 2022-09-09 17:09:19 -05:00
James M. Greene
71efac92ad Add 'preview' input parameter to Action metadata 2022-09-09 17:08:16 -05:00
James M. Greene
b742641b90 Correct organization references 2022-09-09 16:59:57 -05:00
Yoann Chaudet
e4de7aa8e4 Merge pull request #57 from actions/release-instructions
Add release instructions
2022-08-24 11:24:11 -07:00
Yoann Chaudet
84346747a3 v1 2022-08-24 10:55:10 -07:00
Yoann Chaudet
9113cc7efc fix lint 2022-08-24 10:54:29 -07:00
Yoann Chaudet
858592354e Add release instructions 2022-08-24 10:53:23 -07:00
Yoann Chaudet
114f9cc1f8 Merge pull request #56 from actions/cancel
Explicitly handle cancellation on errors
2022-08-24 10:46:21 -07:00
Yoann Chaudet
0dfe0f0668 Merge pull request #55 from actions/formatter
Bring back the formatter
2022-08-24 08:59:01 -07:00
Yoann Chaudet
c7c77bb21c Explicitly handle cancellation on errors 2022-08-23 21:32:40 -07:00
Yoann Chaudet
369d1aed92 Add linter 2022-08-23 17:28:44 -07:00
Yoann Chaudet
4865e84b02 Bring back the formatter 2022-08-23 17:19:21 -07:00
James M. Greene
b627026553 Merge pull request #54 from actions/codeowners-file
Add CODEOWNERS file
2022-08-19 13:29:24 -05:00
James M. Greene
9bd912c0ca Add CODEOWNERS file 2022-08-19 13:28:07 -05:00
James M. Greene
ed034ea1c3 Merge pull request #53 from actions/consistent-release-workflow
Make the major version release workflow consistent with other Actions
2022-08-19 13:27:01 -05:00
James M. Greene
8f9a38d5e7 Update major version only for full releases 2022-08-19 12:33:44 -05:00
James M. Greene
71b1669225 Make the major version release workflow consistent with other Actions
Based on https://github.com/paper-spa/configure-pages/edit/main/.github/workflows/release.yml
2022-08-19 12:26:27 -05:00
James M. Greene
a87638c69c Merge pull request #52 from actions/dependabot/npm_and_yarn/actions/core-1.9.1
Bump @actions/core from 1.6.0 to 1.9.1
2022-08-19 12:16:59 -05:00
James M. Greene
85d735dc73 Update distributables 2022-08-19 12:14:36 -05:00
dependabot[bot]
2e87ed0ac6 Bump @actions/core from 1.6.0 to 1.9.1
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.6.0 to 1.9.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-18 19:49:21 +00:00
James M. Greene
e490850a64 Lowercase the README title 2022-08-10 14:01:18 -05:00
James M. Greene
5743579482 Merge pull request #49 from actions/marketplace-unique-name
Update Action name to enable Marketplace publishing
2022-08-10 14:00:26 -05:00
James M. Greene
5fd268dcdd Update name per suggestion 2022-08-10 12:59:11 -05:00
James M. Greene
fbb46fa661 Update Action name for Marketplace publishing 2022-08-09 22:15:35 -05:00
Mingzi
eaaccf9fc5 Merge pull request #46 from actions/bug-fixing
Fix hardcoded api endpoint and artifact name lookup
2022-08-04 18:06:53 -07:00
yimysty
8daa1e0ead add syntax sugar back 2022-08-04 17:11:26 -07:00
yimysty
99f9079292 roll into right node syntax 2022-08-04 17:09:46 -07:00
yimysty
06d025f427 update node test version 2022-08-04 17:05:51 -07:00
yimysty
7f629c4ce0 apply the syntax 2022-08-04 17:04:26 -07:00
yimysty
35e615a00c check if it's due to "." 2022-08-04 16:56:13 -07:00
yimysty
462df77e16 add more log to debug 2022-08-04 16:52:07 -07:00
yimysty
9ebae0d26b try print error message 2022-08-04 16:25:55 -07:00
yimysty
d0b379e44d move artifact url out of context 2022-08-04 16:23:15 -07:00
yimysty
225abf7840 increase test timeout 2022-08-04 16:13:28 -07:00
yimysty
1f0422c0df add some debug log? 2022-08-04 16:07:20 -07:00
yimysty
85b0d1617e moke get artifact name 2022-08-04 16:02:46 -07:00
yimysty
3e976523d7 adjust pages hard code endpoint + fix artifact look up 2022-08-04 15:43:58 -07:00
Yoann Chaudet
38e42fe573 Merge pull request #42 from actions/more-doc
Update README to document a few things
2022-07-27 13:33:20 -07:00
Yoann Chaudet
44ea2ec0c1 Fix titles 2022-07-26 11:16:01 -07:00
Yoann Chaudet
b4e423ab11 Update README.md
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
2022-07-26 11:14:52 -07:00
Yoann Chaudet
58b7d54130 Update README.md
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
2022-07-26 11:14:35 -07:00
Yoann Chaudet
974e2a6ded Update README.md
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
2022-07-26 11:11:30 -07:00
Yoann Chaudet
f5d172a561 Update README.md
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
2022-07-26 11:11:16 -07:00
Yoann Chaudet
33bba0fd45 Update README.md
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
2022-07-26 11:10:56 -07:00
Yoann Chaudet
1f18c7a3ba Document default too 2022-07-26 11:09:31 -07:00
Yoann Chaudet
86843fdbb5 Update README to document a few things 2022-07-26 10:47:31 -07:00
Mingzi
4d0af465be Merge pull request #41 from DarkC35/patch-1
Fix compare URL in Release
2022-07-05 14:44:51 -07:00
DarkC
bea9114e88 fix compare url in release 2022-07-05 12:24:09 +02:00
Mingzi
41f0a8ab89 Merge pull request #40 from actions/improve-error-message
Improve error message
2022-06-29 10:37:48 -07:00
yimysty
b918908973 run npm generate file 2022-06-29 10:35:08 -07:00
Mingzi
1ae5d2452b Update src/deployment.js
Co-authored-by: Yoann Chaudet <yoannchaudet@github.com>
2022-06-29 10:16:32 -07:00
yimysty
e2219a89b1 fix broken test cases 2022-06-28 18:18:42 -07:00
yimysty
72b116b825 fix unintended changes 2022-06-28 18:01:48 -07:00
yimysty
11a13019c2 adjust debugging message 2022-06-28 17:58:10 -07:00
yimysty
801d74db09 switch to console.log 2022-06-28 17:55:21 -07:00
yimysty
64c69a5fdf normalize error message 2022-06-28 17:50:08 -07:00
yimysty
03d70e4a19 info stack trace 2022-06-28 17:44:21 -07:00
yimysty
64e33b2a0d info stack trace 2022-06-28 17:39:10 -07:00
yimysty
c3d24faf75 info stack trace 2022-06-28 17:38:14 -07:00
yimysty
2b0c6eaf67 try output stacktrace as well 2022-06-28 17:35:03 -07:00
yimysty
358b034ef8 improve error message 2022-06-28 16:08:07 -07:00
Yoann Chaudet
13ef0cb0a0 Merge pull request #39 from actions/joshmgross/add-codeowners
Add CODEOWNERS
2022-06-14 13:30:16 -07:00
Josh Gross
2bf05927ae Add CODEOWNERS 2022-06-14 14:39:58 -04:00
Mingzi
0745e9700c Merge pull request #38 from actions/fix-cancell-token
Fix cancel deployment token is empty
2022-06-08 14:19:14 -07:00
yimysty
43dced9e8c add pack-lock.json 2022-06-08 12:57:34 -07:00
yimysty
fce105b3ea fix unable to cancel deployment due to cancel token nil 2022-06-08 11:47:06 -07:00
Yoann Chaudet
148e2ea9dd Create codeql-analysis.yml 2022-04-26 10:29:56 -07:00
Yoann Chaudet
506f839b97 Merge pull request #31 from fulldecent/patch-1
Correct documentation for reporting interval
2022-04-26 10:26:02 -07:00
Yoann Chaudet
f7a158aceb Merge branch 'main' into patch-1 2022-04-26 10:24:40 -07:00
Yoann Chaudet
ca23c7917e Merge pull request #29 from actions/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-04-26 10:24:21 -07:00
dependabot[bot]
0c60998bd5 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-26 17:21:30 +00:00
Yoann Chaudet
4154a47b87 Merge pull request #34 from actions/dependabot/npm_and_yarn/follow-redirects-1.14.9
Bump follow-redirects from 1.14.4 to 1.14.9
2022-04-26 10:20:47 -07:00
Yoann Chaudet
17fd28439d ci 2022-04-26 10:19:37 -07:00
Yoann Chaudet
0f19a8f78c Update dist 2022-04-26 09:58:05 -07:00
dependabot[bot]
595c840e2a Bump follow-redirects from 1.14.4 to 1.14.9
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.4 to 1.14.9.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.4...v1.14.9)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-26 16:55:09 +00:00
Mingzi
57f2f8bd29 Merge pull request #32 from fulldecent/patch-2
correct spelling of GitHub
2022-04-15 11:21:39 -07:00
Mingzi
68c14dcd2c Merge branch 'main' into patch-2 2022-04-15 11:20:55 -07:00
Jess Bees
a7af90c328 Merge pull request #30 from actions/decouple-telemetry
Remove the support for older dynamic jekyll workflows
2022-04-15 13:51:54 -04:00
William Entriken
ef910bd895 correct spelling of GitHub 2022-04-11 14:30:09 -04:00
William Entriken
53f4e898cd Correct documentation for reporting interval 2022-04-11 14:29:33 -04:00
Jess Bees
62c650c70d Remove the support for older dynamic jekyll workflows
The pages dynamic workflow now decouples telemetry from deploy for 100%
of users, so we can remove this old conditional.
2022-04-04 16:12:36 -04:00
Jess Bees
eaf36f48c9 Merge pull request #24 from actions/decouple-telemetry
Decouple telemetry API call from main action
2022-03-31 12:34:24 -04:00
Jess Bees
01f6ae5af2 Recompile action after pulling in PR suggestions 2022-03-31 12:05:36 -04:00
Jess Bees
82cb77089c Update action.yml
Co-authored-by: James M. Greene <JamesMGreene@github.com>
2022-03-31 11:47:49 -04:00
Jess Bees
ad36b7023a Don't bother converting action input to string
This has been an established pattern with Actions for a long time; we don't have to worry about it changing.

Co-authored-by: James M. Greene <JamesMGreene@github.com>
2022-03-31 11:47:33 -04:00
Jess Bees
32b8b86ff0 Support existing behavior of this action 2022-03-29 15:08:35 -04:00
Jess Bees
a598b2af14 Correctly test for boolean input's truthiness
It gets cast to a string! Eep!
2022-03-29 09:45:18 -04:00
Jess Bees
f511fa4665 Merge branch 'main' into decouple-telemetry 2022-03-29 09:05:35 -04:00
Yoann Chaudet
0e157789db Merge pull request #27 from actions/increase-default-query-interval
Increase default query interval and fix time exceed bug
2022-03-28 12:38:22 -07:00
yimysty
12940a5b99 fix the timeout not honor bug 2022-03-28 12:32:59 -07:00
yimysty
6afc4f2884 slow query seconds 2022-03-28 12:28:46 -07:00
Mingzi
a68b5a4ae1 Merge pull request #26 from actions/parsing-number
Parse correct timeout
2022-03-28 11:21:14 -07:00
yimysty
171a8a05dd update number parsing 2022-03-28 11:19:50 -07:00
Jess Bees
7a1dc4e394 update dist files 2022-03-23 14:56:28 -04:00
Jess Bees
92f6725bee Only emit telemetry when the emit_telemetry input is truthy 2022-03-23 14:40:57 -04:00
Jess Bees
e1279a88ef Don't call the telemetry pre-hook entrypoint 2022-03-23 14:22:16 -04:00
32 changed files with 4360 additions and 3786 deletions

View File

@@ -1,2 +0,0 @@
node_modules/
dist/

View File

@@ -1,19 +1,17 @@
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
"es2021": true,
"node": true,
"jest": true
},
"plugins": ["github"],
"extends": ["eslint:recommended", "prettier", "plugin:github/internal"],
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 12
},
"rules": {
"semi": ["error", "never"]
}
}
},
"ignorePatterns": ["/dist/", "/pre/"]
}

2
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,2 @@
# Default PR reviewers
* @actions/pages

View File

@@ -3,8 +3,10 @@ name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# Changelog
$CHANGES
See details of [all code changes](https://github.com/actions/jekyll-build-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:
- title: '🚀 Features'
labels:

View File

@@ -37,8 +37,13 @@ jobs:
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
echo "Detected uncommitted changes after build in dist folder. See status below:"
git diff
exit 1
fi
if [ "$(git diff --ignore-space-at-eol pre/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build in pre folder. See status below:"
git diff
exit 1
fi
id: diff

34
.github/workflows/check-formatting.yml vendored Normal file
View 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
View 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

70
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: 'CodeQL'
on:
push:
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '40 0 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# 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.
# 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
# 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)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ 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
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -1,7 +1,7 @@
name: Release new action version
name: Release
on:
release:
types: [edited]
types: [released]
workflow_dispatch:
inputs:
TAG_NAME:
@@ -10,19 +10,21 @@ on:
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
permissions:
contents: write
jobs:
update_tag:
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
environment:
# Note: this environment is protected
name: Release
steps:
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@@ -9,20 +9,20 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Set Node.JS
uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Set Node.JS
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
if: github.ref_name == 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
if: github.ref_name == 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1 +1,6 @@
node_modules/
# Ignore build artifacts
/dist/
/pre/
# Ignore all Markdown files
*.md

View File

@@ -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
View File

@@ -0,0 +1,10 @@
# Prettier (formatter) configuration
---
printWidth: 120
tabWidth: 2
useTabs: false
semi: false
singleQuote: true
trailingComma: none
bracketSpacing: true
arrowParens: avoid

1
CODEOWNERS Normal file
View File

@@ -0,0 +1 @@
* @actions/pages

View File

@@ -1,17 +1,89 @@
# Deploy-Pages
# deploy-pages
This deploys artifacts to GitHub Pages.
This action is used to deploy [Actions artifacts][artifacts] to GitHub Pages.
# Scope
## Scope
⚠️ Official support for building Pages with Actions is in public beta at the moment. The scope is currently limited to **public repositories only**.
⚠️ Official support for building Pages with Actions is in public beta at the moment.
# Usage
## Usage
See [action.yml](action.yml)
See [action.yml](action.yml) for the various `inputs` this action supports.
<!-- TODO: document custom workflow -->
For examples that make use of this action, check out our [starter-workflows][starter-workflows] in a variety of frameworks.
# License
This action expects an artifact named `github-pages` to have been created prior to execution. This is done automatically using [`actions/upload-pages-artifact`][upload-pages-artifact].
We recommend this action to be used in a dedicated job:
```yaml
jobs:
# Build job
build:
# <Not provided for brevity>
# At a minimum this job should upload artifacts using actions/upload-pages-artifact
# Deploy job
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
```
## Security considerations
There are a few important considerations to be aware of:
1. The artifact being deployed must have been uploaded in a previous step, either in the same job or a separate job that doesn't execute until the upload is complete.
2. The job that executes the deployment must at minimum have the following permissions:
- `pages: write`
- `id-token: write`
3. The deployment should target the `github-pages` environment (you may use a different environment name if needed, but this is not recommended.)
4. If your Pages site is using a source branch, the deployment must originate from this source branch unless [your environment is protected][environment-protection] in which case the environment protection rules take precedence over the source branch rule
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
The scripts and documentation in this project are released under the [MIT License](LICENSE).
<!-- references -->
[starter-workflows]: https://github.com/actions/starter-workflows/tree/main/pages
[upload-pages-artifact]: https://github.com/actions/upload-pages-artifact
[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
[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

View File

@@ -1,10 +1,17 @@
name: 'Deploy to GitHub Pages'
description: 'A GitHub Action to deploy an artifact to GitHub Pages'
name: 'Deploy GitHub Pages site'
description: 'A GitHub Action to deploy an artifact as a GitHub Pages site'
author: 'GitHub'
runs:
using: 'node16'
main: 'dist/index.js'
pre: 'pre/index.js'
inputs:
emit_telemetry:
description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
required: false
default: 'false'
conclusion:
description: 'The status of the previous build.'
required: false
token:
description: 'GitHub token'
default: ${{ github.token }}
@@ -12,15 +19,23 @@ inputs:
timeout:
description: 'Time in milliseconds after which to timeout and cancel the deployment (default: 10 minutes)'
required: false
default: "600000"
default: '600000'
error_count:
description: 'Maximum number of status report errors before cancelling a deployment (default: 10)'
required: false
default: "10"
default: '10'
reporting_interval:
description: 'Time in milliseconds between two deployment status report (default: 1 second)'
description: 'Time in milliseconds between two deployment status report (default: 5 seconds)'
required: false
default: "1000"
default: '5000'
artifact_name:
description: 'Name of the artifact to deploy'
required: false
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:
page_url:
description: 'URL to deployed Github Pages'
description: 'URL to deployed GitHub Pages'

View File

@@ -1 +0,0 @@
module.exports = {presets: ['@babel/preset-env']}

2226
dist/index.js vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

13
dist/licenses.txt vendored
View File

@@ -258,3 +258,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
uuid
MIT
The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,5 +0,0 @@
module.exports = {
transform: {
'^.+\\.(js|jsx)$': 'babel-jest'
}
}

2790
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,17 +4,11 @@
"description": "Deploy an actions artifact to GitHub Pages",
"main": "./dist/index.js",
"dependencies": {
"@actions/artifact": "^0.5.2",
"@actions/core": "^1.6.0",
"@babel/plugin-transform-runtime": "^7.16.0",
"@actions/core": "^1.9.1",
"axios": "^0.24.0",
"regenerator-runtime": "^0.13.9",
"axios-retry": "^3.2.4",
"tar": "^6.1.11"
"axios-retry": "^3.2.4"
},
"devDependencies": {
"@babel/preset-env": "^7.16.0",
"@github/prettier-config": "0.0.4",
"@vercel/ncc": "^0.31.1",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
@@ -24,14 +18,17 @@
"prettier": "^2.4.1"
},
"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",
"test": "jest",
"all": "npm run lint && npm run prepare && npm run test"
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/paper-spa/deploy-pages.git"
"url": "git+https://github.com/actions/deploy-pages.git"
},
"keywords": [
"GitHub",
@@ -40,7 +37,7 @@
"author": "GitHub",
"license": "MIT",
"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"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -258,3 +258,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
uuid
MIT
The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -10,7 +10,10 @@ function getRequiredVars() {
buildVersion: process.env.GITHUB_SHA,
buildActor: process.env.GITHUB_ACTOR,
actionsId: process.env.GITHUB_ACTION,
githubToken: core.getInput('token')
githubToken: core.getInput('token'),
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
artifactName: core.getInput('artifact_name') ?? 'github-pages',
isPreview: core.getInput('preview') === 'true'
}
}

View File

@@ -1,5 +1,3 @@
require('regenerator-runtime/runtime')
const core = require('@actions/core')
const axios = require('axios')
@@ -7,150 +5,227 @@ const axios = require('axios')
const getContext = require('./context')
const errorStatus = {
'unknown_status' : 'Unable to get deployment status.',
'not_found' : 'Deployment not found.',
'deployment_attempt_error' : 'Deployment temporarily failed, a retry will be automatically scheduled...'
unknown_status: 'Unable to get deployment status.',
not_found: 'Deployment not found.',
deployment_attempt_error: 'Deployment temporarily failed, a retry will be automatically scheduled...'
}
class Deployment {
constructor() {
const context = getContext()
this.runTimeUrl = context.runTimeUrl
this.repositoryNwo = context.repositoryNwo
this.runTimeToken = context.runTimeToken
this.buildVersion = context.buildVersion
this.buildActor = context.buildActor
this.actionsId = context.workflowRun
this.githubToken = context.githubToken
this.workflowRun = context.workflowRun
this.requestedDeployment = false
this.deploymentInfo = null
}
constructor() {
const context = getContext()
this.runTimeUrl = context.runTimeUrl
this.repositoryNwo = context.repositoryNwo
this.runTimeToken = context.runTimeToken
this.buildVersion = context.buildVersion
this.buildActor = context.buildActor
this.actionsId = context.workflowRun
this.githubToken = context.githubToken
this.workflowRun = context.workflowRun
this.requestedDeployment = false
this.deploymentInfo = null
this.githubApiUrl = context.githubApiUrl
this.artifactName = context.artifactName
this.isPreview = context.isPreview === true
}
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
// by creating a deployment with that artifact
async create(idToken) {
try {
core.info(`Actor: ${this.buildActor}`)
core.info(`Action ID: ${this.actionsId}`)
const pagesDeployEndpoint = `https://api.github.com/repos/${this.repositoryNwo}/pages/deployment`
const artifactExgUrl = `${this.runTimeUrl}_apis/pipelines/workflows/${this.workflowRun}/artifacts?api-version=6.0-preview`
core.info(`Artifact URL: ${artifactExgUrl}`)
const {data} = await axios.get(artifactExgUrl, {
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
// by creating a deployment with that artifact
async create(idToken) {
try {
core.info(`Actor: ${this.buildActor}`)
core.info(`Action ID: ${this.actionsId}`)
const pagesDeployEndpoint = `${this.githubApiUrl}/repos/${this.repositoryNwo}/pages/deployment`
const artifactExgUrl = `${this.runTimeUrl}_apis/pipelines/workflows/${this.workflowRun}/artifacts?api-version=6.0-preview`
core.info(`Artifact URL: ${artifactExgUrl}`)
const { data } = await axios.get(artifactExgUrl, {
headers: {
Authorization: `Bearer ${this.runTimeToken}`,
'Content-Type': 'application/json'
}
})
core.info(JSON.stringify(data))
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: {
Authorization: `Bearer ${this.runTimeToken}`,
'Content-Type': 'application/json'
Authorization: `token ${this.githubToken}`
}
})
core.info(JSON.stringify(data))
if (data.value.length == 0) {
throw new Error('No uploaded artifact was found! Please check if there are any errors at build step.')
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)
}
const artifactUrl = `${data.value[0].url}&%24expand=SignedContent`
const payload = {
artifact_url: artifactUrl,
pages_build_version: this.buildVersion,
oidc_token: idToken
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
}
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: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${this.githubToken}`,
'Content-type': 'application/json'
}
})
this.requestedDeployment = true
core.info(`Created deployment for ${this.buildVersion}`)
core.info(JSON.stringify(response.data))
this.deploymentInfo = response.data
} catch (error) {
core.info(`Failed to create deployment for ${this.buildVersion}.`)
if (error.response && error.response.data) {
core.info(JSON.stringify(error.response.data))
}
core.setFailed(error)
throw error
}
}
// Poll the deployment endpoint for status
async check() {
try {
const statusUrl = this.deploymentInfo != null ?
this.deploymentInfo["status_url"] :
`https://api.github.com/repos/${this.repositoryNwo}/pages/deployment/status/${process.env['GITHUB_SHA']}`
core.setOutput('page_url', this.deploymentInfo != null ? this.deploymentInfo["page_url"] : "")
const timeout = core.getInput('timeout')
const reportingInterval = Number(core.getInput('reporting_interval'))
const maxErrorCount = 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 }

View File

@@ -1,45 +1,28 @@
require('regenerator-runtime/runtime')
// This package assumes a site has already been built and the files exist in the current workspace
// If there's an artifact named `artifact.tar`, it can upload that to actions on its own,
// without the user having to do the tar process themselves.
const core = require('@actions/core')
// const github = require('@actions/github'); // TODO: Not used until we publish API endpoint to the @action/github package
const axios = require('axios')
const {Deployment} = require('./deployment')
const { Deployment } = require('./deployment')
const deployment = new Deployment()
// TODO: If the artifact hasn't been created, we can create it and upload to artifact storage ourselves
// const tar = require('tar')
async function cancelHandler(evtOrExitCodeOrError) {
try {
if (deployment.requestedDeployment) {
const pagesCancelDeployEndpoint = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/cancel/${process.env.GITHUB_SHA}`
await axios.put(
pagesCancelDeployEndpoint,
{},
{
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
'Content-type': 'application/json'
}
}
)
core.info(`Deployment cancelled with ${pagesCancelDeployEndpoint}`)
}
} catch (e) {
console.info('Deployment cancellation failed', e)
}
await deployment.cancel()
process.exit(isNaN(+evtOrExitCodeOrError) ? 1 : +evtOrExitCodeOrError)
}
async function main() {
let idToken = ''
try {
idToken = await core.getIDToken()
} catch (error) {
console.log(error)
core.setFailed(`Ensure GITHUB_TOKEN has permission "idToken: write".`)
return
}
try {
const idToken = await core.getIDToken()
await deployment.create(idToken)
await deployment.check()
} catch (error) {
@@ -52,4 +35,9 @@ process.on('SIGINT', cancelHandler)
process.on('SIGTERM', cancelHandler)
// Main
main().then(() => require('./pre'))
const emitTelemetry = core.getInput('emit_telemetry')
if (emitTelemetry === 'true') {
require('./pre')
} else {
main()
}

View File

@@ -5,16 +5,14 @@ const path = require('path')
const nock = require('nock')
const axios = require('axios')
const { expect, jest } = require('@jest/globals')
const {Deployment} = require('./deployment')
const { Deployment } = require('./deployment')
describe('with all environment variables set', () => {
beforeEach(() => {
process.env.ACTIONS_RUNTIME_URL = 'my-url'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
process.env.GITHUB_TOKEN = 'gha-token'
process.env.GITHUB_SHA = '123abc'
process.env.GITHUB_ACTOR = 'monalisa'
@@ -22,6 +20,11 @@ describe('with all environment variables set', () => {
process.env.GITHUB_ACTION_PATH = 'something'
})
afterEach(() => {
// Remove mock for `core.getInput('preview')`
delete process.env.INPUT_PREVIEW
})
it('Executes cleanly', done => {
const ip = path.join(__dirname, './index.js')
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 => {
delete process.env.ACTIONS_RUNTIME_URL
const ip = path.join(__dirname, './index.js')
cp.exec(`node ${ip}`, {env: process.env}, (err, stdout) => {
expect(stdout).toBe("")
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
expect(stdout).toBe('')
expect(err).toBeTruthy()
expect(err.code).toBe(1)
done()
@@ -49,12 +52,22 @@ describe('create', () => {
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
process.env.GITHUB_TOKEN = 'gha-token'
process.env.GITHUB_SHA = '123abc'
process.env.GITHUB_ACTOR = 'monalisa'
process.env.GITHUB_ACTION = '__monalisa/octocat'
process.env.GITHUB_ACTION_PATH = 'something'
jest.spyOn(core, 'getInput').mockImplementation(param => {
switch (param) {
case 'artifact_name':
return 'github-pages'
case 'token':
return process.env.GITHUB_TOKEN
default:
return process.env[`INPUT_${param.toUpperCase()}`] || ''
}
})
jest.spyOn(core, 'setOutput').mockImplementation(param => {
return param
@@ -72,10 +85,16 @@ describe('create', () => {
it('can successfully create a deployment', async () => {
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`)
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
.reply(200, { value: [{ url: 'https://fake-artifact.com' }] })
.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')
@@ -85,7 +104,7 @@ describe('create', () => {
await deployment.create(fakeJwt)
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',
pages_build_version: 'valid-build-version',
@@ -94,17 +113,61 @@ describe('create', () => {
{
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: 'Bearer ',
Authorization: `Bearer gha-token`,
'Content-type': 'application/json'
}
}
)
expect(core.setFailed).not.toHaveBeenCalled()
expect(core.info).toHaveBeenCalledWith(
'Created deployment for valid-build-version'
expect(core.info).toHaveBeenCalledWith('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()
})
@@ -112,7 +175,7 @@ describe('create', () => {
process.env.GITHUB_SHA = 'invalid-build-version'
const scope = nock(`http://my-url`)
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
.reply(200, { value: [{ url: 'https://invalid-artifact.com' }] })
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
axios.post = jest.fn().mockRejectedValue({
status: 400
@@ -123,9 +186,8 @@ describe('create', () => {
try {
deployment.create()
} catch (err) {
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',
pages_build_version: 'invalid-build-version'
@@ -139,15 +201,12 @@ describe('create', () => {
}
)
expect(core.info).toHaveBeenLastCalledWith(
'Failed to create deployment for invalid-build-version.'
)
expect(core.info).toHaveBeenLastCalledWith('Failed to create deployment for invalid-build-version.')
expect(core.setFailed).toHaveBeenCalledWith({ status: 400 })
scope.done()
}
})
})
describe('check', () => {
@@ -155,12 +214,13 @@ describe('check', () => {
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
process.env.GITHUB_TOKEN = 'gha-token'
process.env.GITHUB_SHA = '123abc'
process.env.GITHUB_ACTOR = 'monalisa'
process.env.GITHUB_ACTION = '__monalisa/octocat'
process.env.GITHUB_ACTION_PATH = 'something'
process.env.ARTIFACT_NAME = 'github-pages'
jest.spyOn(core, 'setOutput').mockImplementation(param => {
return param
@@ -209,7 +269,7 @@ describe('check', () => {
`https://api.github.com/repos/${repositoryNwo}/pages/deployment/status/${buildVersion}`,
{
headers: {
Authorization: 'token '
Authorization: 'token gha-token'
}
}
)

View File

@@ -16,17 +16,18 @@ axiosRetry(axios, {
}
})
const {Deployment} = require('./deployment')
const { Deployment } = require('./deployment')
async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment()
const telemetryUrl = `https://api.github.com/repos/${deployment.repositoryNwo}/pages/telemetry`
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
const conclusion = core.getInput('conclusion') || null
core.info(`Sending telemetry for run id ${deployment.workflowRun}: ${conclusion}`)
await axios
.post(
telemetryUrl,
{github_run_id: deployment.workflowRun},
{ github_run_id: deployment.workflowRun, conclusion },
{
headers: {
Accept: 'application/vnd.github.v3+json',
@@ -54,4 +55,4 @@ async function main() {
main()
module.exports = {emitTelemetry}
module.exports = { emitTelemetry }

View File

@@ -2,21 +2,20 @@ const core = require('@actions/core')
const process = require('process')
const axios = require('axios')
const {expect, jest} = require('@jest/globals')
const {emitTelemetry} = require('./pre')
const { emitTelemetry } = require('./pre')
describe('emitTelemetry', () => {
beforeAll(() => {
process.env.ACTIONS_RUNTIME_URL = 'my-url'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
process.env.GITHUB_REPOSITORY = 'paper-spa/is-awesome'
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
process.env.GITHUB_TOKEN = 'gha-token'
process.env.GITHUB_SHA = '123abc'
process.env.GITHUB_ACTOR = 'monalisa'
process.env.GITHUB_ACTION = '__monalisa/octocat'
process.env.GITHUB_ACTION_PATH = 'something'
process.env.INPUT_CONCLUSION = 'success'
jest.spyOn(core, 'setOutput').mockImplementation(param => {
return param
@@ -45,9 +44,10 @@ describe('emitTelemetry', () => {
emitTelemetry()
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: {