Compare commits

...

74 Commits

Author SHA1 Message Date
James M. Greene
af48cf94a4 Merge pull request #156 from actions/deprecation-cleanup
Remove deprecated input parameters
2023-04-18 09:59:28 -05:00
James M. Greene
b39c421b98 Remove deprecated input parameters 2023-04-18 01:13:17 -05:00
James M. Greene
176fcdbd0d Merge pull request #155 from actions/classic-grantbirki-driveby
General Repository Improvements
2023-04-18 00:43:13 -05:00
James M. Greene
b8a0d0233e Alphabetize the npm scripts 2023-04-18 00:34:47 -05:00
James M. Greene
31bb4568ea Move coverage badge to root directory 2023-04-18 00:32:50 -05:00
James M. Greene
6657d340c9 Rename 'functions' directory to 'internal' 2023-04-18 00:32:13 -05:00
James M. Greene
efce2761be Revert Actions workflow names since we're overriding in badges 2023-04-18 00:18:00 -05:00
James M. Greene
c77de140c8 Use shields.io for more consistent badges 2023-04-18 00:15:14 -05:00
James M. Greene
0a6b5a09eb Add badge for latest release 2023-04-18 00:04:23 -05:00
James M. Greene
ddf1436b98 Reorder badges 2023-04-17 23:57:32 -05:00
James M. Greene
b463fdb52c Shorten workflow names for better badges 2023-04-17 23:54:37 -05:00
James M. Greene
26c37d6a64 Wording tweak 2023-04-17 23:51:57 -05:00
James M. Greene
16c932f680 Update contribution instructions 2023-04-17 23:51:13 -05:00
James M. Greene
e93f066622 Use real version tag in example usage 2023-04-17 23:41:47 -05:00
James M. Greene
0d1bd15af6 Minor wording update in README 2023-04-17 23:37:32 -05:00
James M. Greene
5aacbeac9b Update README with info on Environment Variables set 2023-04-17 23:35:32 -05:00
James M. Greene
3a8a04e5ad Pin release-drafter action usage since we cannot trust outside orgs 2023-04-17 23:29:20 -05:00
James M. Greene
324f764c2b Unpin actions usage since we trust our own org 2023-04-17 23:27:04 -05:00
James M. Greene
5daf42835f Tidy up comment so Dependabot can update it 2023-04-17 23:26:12 -05:00
James M. Greene
dab0b0f83d Remove unnecessary checkout from release drafting workflow 2023-04-17 23:24:42 -05:00
James M. Greene
a8b1dc44fa Actions naming cleanup/reverts 2023-04-17 23:24:24 -05:00
James M. Greene
20bd69d98b Remove 'ci-test' script in favor of generating coverage badges as part of the 'all' script 2023-04-17 23:18:55 -05:00
James M. Greene
f7c37e718b Remove .eslintignore file in favor of existing .eslintrc.json ignore patterns 2023-04-17 23:17:34 -05:00
James M. Greene
425b204f49 Use node-version-file parameter instead of an extra step 2023-04-14 15:52:00 -05:00
grantbirki
9c5eb6975b remove required test coverage section 2023-04-14 21:32:12 +01:00
grantbirki
c667db85ec bundle 2023-04-14 21:29:15 +01:00
grantbirki
c05cd8b1e8 at least 70% coverage 2023-04-14 21:29:12 +01:00
grantbirki
571bf8a87f catches an error when trying to cancel a deployment - test 2023-04-14 21:26:09 +01:00
grantbirki
36f9337a64 test early exit on a deployment cancel request 2023-04-14 21:20:52 +01:00
grantbirki
c38b3699e6 exits early when deployment is not in progress - test 2023-04-14 21:10:57 +01:00
grantbirki
44c5eaa46e add check when no deployment is found 2023-04-14 21:04:16 +01:00
grantbirki
7b5216ce57 bundle and fmt 2023-04-14 21:01:12 +01:00
grantbirki
5f3aba0651 reduce passing coverage while writing tests 2023-04-14 20:59:23 +01:00
grantbirki
3194543231 update tests 2023-04-14 20:58:13 +01:00
grantbirki
515e39edbf structuring tests and functions 2023-04-14 20:43:44 +01:00
grantbirki
dbac87a7c1 new lines 2023-04-13 23:34:29 +01:00
grantbirki
f0789de653 structure readme 2023-04-13 23:26:36 +01:00
grantbirki
b98f9c9766 add inputs and outputs to the readme 2023-04-13 23:23:56 +01:00
grantbirki
54f29598ff npm update all the things 2023-04-13 23:17:15 +01:00
grantbirki
adb13af2ed add coverage badge to readme 2023-04-13 23:13:38 +01:00
grantbirki
68c51d2103 write coverage badge 2023-04-13 23:12:57 +01:00
grantbirki
c21c0b1aa2 enforce 100% test coverage 2023-04-13 23:11:46 +01:00
grantbirki
f28358b33b update ci-test and jest 2023-04-13 23:10:02 +01:00
grantbirki
f5eb43ca84 update readme 2023-04-13 23:08:45 +01:00
grantbirki
ddc80bafdb add a CONTRIBUTING file 2023-04-13 23:01:41 +01:00
grantbirki
f1d846dabc move test file 2023-04-13 22:59:58 +01:00
grantbirki
174365715e init the coverage badge 2023-04-13 22:58:09 +01:00
grantbirki
215f5a3008 update all workflow files to use the .node-version file in the root of the repo 2023-04-13 22:57:59 +01:00
grantbirki
ff86b6ce87 update version in package file 2023-04-13 22:57:36 +01:00
grantbirki
79773139e9 add new root level files 2023-04-13 22:57:24 +01:00
grantbirki
aaa3e0131c remove duplicate CODEOWNERS file 2023-04-13 22:51:51 +01:00
James M. Greene
f81ad71d2e Merge pull request #150 from actions/dependabot/npm_and_yarn/prettier-2.8.7
Bump prettier from 2.8.6 to 2.8.7
2023-03-31 22:15:26 -05:00
dependabot[bot]
adbdac1229 Bump prettier from 2.8.6 to 2.8.7
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.6 to 2.8.7.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.6...2.8.7)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 03:12:58 +00:00
James M. Greene
c124166064 Merge pull request #149 from actions/dependabot/npm_and_yarn/eslint-plugin-github-4.7.0
Bump eslint-plugin-github from 4.6.1 to 4.7.0
2023-03-31 22:11:04 -05:00
dependabot[bot]
d4e8b127fc Bump eslint-plugin-github from 4.6.1 to 4.7.0
Bumps [eslint-plugin-github](https://github.com/github/eslint-plugin-github) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/github/eslint-plugin-github/releases)
- [Commits](https://github.com/github/eslint-plugin-github/compare/v4.6.1...v4.7.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-github
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 19:03:30 +00:00
James M. Greene
777703e175 Merge pull request #147 from actions/dependabot/npm_and_yarn/prettier-2.8.6
Bump prettier from 2.8.4 to 2.8.6
2023-03-22 15:55:56 -05:00
dependabot[bot]
34029d15d3 Bump prettier from 2.8.4 to 2.8.6
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.6.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.6)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-22 20:55:16 +00:00
James M. Greene
4cc630477b Merge pull request #142 from actions/dependabot/npm_and_yarn/eslint-config-prettier-8.8.0
Bump eslint-config-prettier from 8.7.0 to 8.8.0
2023-03-22 15:53:52 -05:00
dependabot[bot]
9f07c73fa5 Bump eslint-config-prettier from 8.7.0 to 8.8.0
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.7.0 to 8.8.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.7.0...v8.8.0)

---
updated-dependencies:
- dependency-name: eslint-config-prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-22 20:53:15 +00:00
James M. Greene
6ff0b5a17e Merge pull request #103 from actions/dependabot/npm_and_yarn/vercel/ncc-0.36.1
Bump @vercel/ncc from 0.31.1 to 0.36.1
2023-03-22 15:33:21 -05:00
github-actions[bot]
703ddcc7b8 Update distributables after Dependabot 🤖 2023-03-21 03:47:19 +00:00
dependabot[bot]
ca55b66fad Bump @vercel/ncc from 0.31.1 to 0.36.1
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.31.1 to 0.36.1.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.31.1...0.36.1)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-21 03:46:47 +00:00
James M. Greene
73e62e6511 Merge pull request #140 from actions/cut-v2
Update the deployment API endpoints used by the api-client module
2023-03-17 11:59:36 -05:00
Jess Bees
b254707f5c Update the deployment API endpoints used by the api-client module 2023-03-17 11:54:20 -05:00
James M. Greene
dcda0bb2bc Merge pull request #139 from actions/revert-api-shift
Revert shifted Deployments API endpoint usage
2023-03-17 11:48:46 -05:00
James M. Greene
7ed610198d Update distributables with correct dependencies 2023-03-17 11:21:12 -05:00
James M. Greene
30c6e00b35 Revert shifted API usage from https://github.com/actions/deploy-pages/pull/136
Fixes https://github.com/actions/deploy-pages/issues/137
2023-03-17 11:18:26 -05:00
Jess Bees
7fec4b245d Merge pull request #136 from actions/update-api-routes
Update the deployment API endpoints used by the api-client module
2023-03-16 09:46:32 -04:00
Jess Bees
73594fd4fc Update the deployment API endpoints used by the api-client module 2023-03-15 16:01:03 -04:00
James M. Greene
e690f03220 Merge pull request #133 from actions/dependabot/npm_and_yarn/eslint-8.36.0
Bump eslint from 8.35.0 to 8.36.0
2023-03-14 20:35:28 -05:00
dependabot[bot]
c3f52457f2 Bump eslint from 8.35.0 to 8.36.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.35.0 to 8.36.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.35.0...v8.36.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-15 01:34:39 +00:00
James M. Greene
72f6a10043 Merge pull request #134 from actions/dependabot/npm_and_yarn/actions/http-client-2.1.0
Bump @actions/http-client from 2.0.1 to 2.1.0
2023-03-14 20:33:58 -05:00
github-actions[bot]
c9063b9615 Update distributables after Dependabot 🤖 2023-03-13 19:12:38 +00:00
dependabot[bot]
6e7778e824 Bump @actions/http-client from 2.0.1 to 2.1.0
Bumps [@actions/http-client](https://github.com/actions/toolkit/tree/HEAD/packages/http-client) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/http-client/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/http-client)

---
updated-dependencies:
- dependency-name: "@actions/http-client"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-13 19:12:02 +00:00
27 changed files with 1756 additions and 1583 deletions

View File

@@ -13,5 +13,5 @@
"rules": {
"semi": ["error", "never"]
},
"ignorePatterns": ["/dist/", "/pre/"]
"ignorePatterns": ["/dist/"]
}

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
dist/** -diff linguist-generated=true

View File

@@ -21,12 +21,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Set Node.js 16.x
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version-file: '.node-version'
cache: npm
- name: Install dependencies
@@ -36,9 +37,17 @@ jobs:
run: npm run prepare
- name: Compare the expected and actual dist/ directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build in dist folder. See status below:"
git diff
exit 1
fi
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/

View File

@@ -1,4 +1,4 @@
name: Checking formatting
name: Check formatting
on:
push:
@@ -24,8 +24,8 @@ jobs:
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
node-version-file: '.node-version'
cache: npm
- name: Install dependencies
run: npm ci

View File

@@ -1,4 +1,4 @@
name: Check linter
name: Check linting
on:
push:
@@ -24,8 +24,8 @@ jobs:
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
node-version-file: '.node-version'
cache: npm
- name: Install dependencies
run: npm ci

View File

@@ -9,7 +9,7 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: 'CodeQL'
name: CodeQL
on:
push:
@@ -37,7 +37,7 @@ jobs:
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.

View File

@@ -11,7 +11,6 @@ jobs:
draft-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@569eb7ee3a85817ab916c8f8ff03a5bd96c9c83e # v5.23.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -29,8 +29,8 @@ jobs:
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
node-version-file: '.node-version'
cache: npm
- name: Install dependencies
run: npm ci

View File

@@ -1,4 +1,4 @@
name: Run Tests
name: Run tests
on:
push:
@@ -19,8 +19,8 @@ jobs:
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
node-version-file: '.node-version'
cache: npm
- name: Install dependencies
run: npm ci

2
.gitignore vendored
View File

@@ -64,4 +64,4 @@ typings/
.env
# next.js build output
.next
.next

1
.node-version Normal file
View File

@@ -0,0 +1 @@
18.9.0

View File

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

29
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,29 @@
# Contributing 💻
All contributions are welcome and greatly appreciated!
## Steps to Contribute 💡
> Check the `.node-version` file in the root of this repo so see what version of Node.js is required for local development - note, this can be different from the version of Node.js which runs the Action on GitHub runners. It is suggested to download [nodenv](https://github.com/nodenv/nodenv) which uses this file and manages your Node.js versions for you
1. Fork this repository
2. Make your changes
3. [Test](#testing-) your changes locally
4. Before opening a pull request, please run `npm run all` to verify formatting, linting, tests, generated files, etc.
5. Commit and push your changes to your fork
6. Open a pull request back to this repository
7. Wait for an approval or changes requested from the maintainers of this repository
After merging the pull request, the maintainers of this repository will create a new release with those changes included. After that, everyone can utilize the newly integrated changes in their own Actions workflows and enjoy your awesome improvements!
## Testing 🧪
### Running the test suite (required)
Simply run the following command to execute the entire test suite:
```bash
npm test
```
> Note: This requires that you have already run `npm install`.

View File

@@ -1,10 +1,8 @@
# deploy-pages
# deploy-pages 🚀
This action is used to deploy [Actions artifacts][artifacts] to GitHub Pages.
[![Release](https://img.shields.io/github/v/release/actions/deploy-pages?label=Release&logo=github)](https://github.com/actions/deploy-pages/releases/latest) [![Linting](https://img.shields.io/github/actions/workflow/status/actions/deploy-pages/check-linter.yml?label=Linting&logo=github)](https://github.com/actions/deploy-pages/actions/workflows/check-linter.yml) [![Formatting](https://img.shields.io/github/actions/workflow/status/actions/deploy-pages/check-formatting.yml?label=Formatting&logo=github)](https://github.com/actions/deploy-pages/actions/workflows/check-formatting.yml) [![Tests](https://img.shields.io/github/actions/workflow/status/actions/deploy-pages/test.yml?label=Tests&logo=github)](https://github.com/actions/deploy-pages/actions/workflows/test.yml) ![Coverage](./coverage_badge.svg) [![Distributables](https://img.shields.io/github/actions/workflow/status/actions/deploy-pages/check-dist.yml?label=Distributables&logo=github)](https://github.com/actions/deploy-pages/actions/workflows/check-dist.yml) [![CodeQL](https://img.shields.io/github/actions/workflow/status/actions/deploy-pages/codeql-analysis.yml?label=CodeQL&logo=github)](https://github.com/actions/deploy-pages/actions/workflows/codeql-analysis.yml)
## Scope
⚠️ Official support for building Pages with Actions is in public beta at the moment.
This action is used to deploy [Actions artifacts][artifacts] to [GitHub Pages](https://pages.github.com/).
## Usage
@@ -12,7 +10,7 @@ See [action.yml](action.yml) for the various `inputs` this action supports.
For examples that make use of this action, check out our [starter-workflows][starter-workflows] in a variety of frameworks.
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].
This action expects an artifact named `github-pages` to have been created prior to execution. This is done automatically when using [`actions/upload-pages-artifact`][upload-pages-artifact].
We recommend this action to be used in a dedicated job:
@@ -43,10 +41,37 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action
```
## Security considerations
### Inputs 📥
| Input | Required? | Default | Description |
| ----- | --------- | ------- | ----------- |
| `token` | `true` | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! |
| `timeout` | `false` | `"600000"` | Time in milliseconds after which to timeout and cancel the deployment (default: 10 minutes) |
| `error_count` | `false` | `"10"` | Maximum number of status report errors before cancelling a deployment (default: 10) |
| `reporting_interval` | `false` | `"5000"` | Time in milliseconds between two deployment status report (default: 5 seconds) |
| `artifact_name` | `false` | `"github-pages"` | The name of the artifact to deploy |
| `preview` | `false` | `"false"` | 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!) |
### Outputs 📤
| Output | Description |
| ------ | ----------- |
| `page_url` | The URL of the deployed Pages site |
### Environment Variables 🌎
| Variable | Description |
| -------- | ----------- |
| `GITHUB_PAGES` | This environment variable is created and set to the string value `"true"` so that framework build tools may choose to differentiate their output based on the intended target hosting platform. |
## Scope
⚠️ Official support for building Pages with Actions is in public beta at the moment.
## Security Considerations
There are a few important considerations to be aware of:
@@ -60,9 +85,9 @@ There are a few important considerations to be aware of:
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)
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 will configure it by default for you).
# Release instructions
## Release Instructions
In order to release a new version of this Action:

View File

@@ -5,15 +5,6 @@ runs:
using: 'node16'
main: 'dist/index.js'
inputs:
emit_telemetry:
deprecationMessage: 'Use of this input causes the action to do nothing. You should remove this build step from your workflow.'
description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
required: false
default: 'false'
conclusion:
deprecationMessage: 'Use of this input does nothing as it was part of the deprecated `emit_telemetry` flow. You should remove this parameter from your workflow.'
description: 'The status of the previous build.'
required: false
token:
description: 'GitHub token'
default: ${{ github.token }}

1
coverage_badge.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 73.13%"><title>Coverage: 73.13%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#e05d44"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">73.13%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">73.13%</text></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

214
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

2647
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,28 @@
{
"name": "deploy-pages",
"version": "0.0.1",
"version": "0.0.0",
"description": "Deploy an actions artifact to GitHub Pages",
"main": "./dist/index.js",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@actions/http-client": "^2.0.1",
"@actions/http-client": "^2.1.0",
"@octokit/request-error": "^3.0.3",
"http-status-messages": "^1.1.0"
},
"devDependencies": {
"@vercel/ncc": "^0.31.1",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-github": "^4.6.1",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-github": "^4.7.0",
"jest": "^29.5.0",
"nock": "^13.3.0",
"prettier": "^2.8.4"
"prettier": "^2.8.7",
"make-coverage-badge": "^1.2.0"
},
"scripts": {
"all": "npm run format && npm run lint && npm run prepare && npm run test",
"all": "npm run format && npm run lint && npm run prepare && npm run test && npm run coverage-badge",
"coverage-badge": "make-coverage-badge --output-path ./coverage_badge.svg",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "DEBUG=eslint:cli-engine eslint --fix .",
@@ -41,5 +43,22 @@
"bugs": {
"url": "https://github.com/actions/deploy-pages/issues"
},
"homepage": "https://github.com/actions/deploy-pages#readme"
"homepage": "https://github.com/actions/deploy-pages#readme",
"jest": {
"coverageReporters": [
"json-summary",
"text",
"lcov"
],
"collectCoverage": true,
"collectCoverageFrom": [
"./src/**"
],
"coverageThreshold": {
"global": {
"lines": 70,
"statements": 70
}
}
}
}

View File

@@ -0,0 +1,38 @@
const process = require('process')
const cp = require('child_process')
const path = require('path')
describe('with all environment variables set', () => {
beforeEach(() => {
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 = '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'
})
it('executes cleanly', done => {
const ip = path.join(__dirname, '../index.js')
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
expect(stdout).toMatch(/::debug::all variables are set/)
done()
})
})
})
describe('with variables missing', () => {
it('execution fails if there are missing variables', done => {
delete process.env.ACTIONS_RUNTIME_URL
const ip = path.join(__dirname, '../index.js')
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
expect(stdout).toBe('')
expect(err).toBeTruthy()
expect(err.code).toBe(1)
done()
})
})
})

View File

@@ -1,51 +1,14 @@
const core = require('@actions/core')
const process = require('process')
const cp = require('child_process')
const path = require('path')
const nock = require('nock')
const { Deployment } = require('./deployment')
const { Deployment } = require('../../internal/deployment')
const fakeJwt =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNjllMWIxOC1jOGFiLTRhZGQtOGYxOC03MzVlMzVjZGJhZjAiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjIiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM4ODI4MDI4LCJleHAiOjE2Mzg4Mjg5MjgsImlhdCI6MTYzODgyODYyOH0.1wyupfxu1HGoTyIqatYg0hIxy2-0bMO-yVlmLSMuu2w'
describe('with all environment variables set', () => {
beforeEach(() => {
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 = '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'
})
it('executes cleanly', done => {
const ip = path.join(__dirname, './index.js')
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
expect(stdout).toMatch(/::debug::all variables are set/)
done()
})
})
})
describe('with variables missing', () => {
it('execution fails if there are missing variables', done => {
delete process.env.ACTIONS_RUNTIME_URL
const ip = path.join(__dirname, './index.js')
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
expect(stdout).toBe('')
expect(err).toBeTruthy()
expect(err.code).toBe(1)
done()
})
})
})
describe('Deployment', () => {
beforeEach(() => {
jest.clearAllMocks()
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
@@ -100,13 +63,13 @@ describe('Deployment', () => {
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})
@@ -138,14 +101,14 @@ describe('Deployment', () => {
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt,
preview: true
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome',
preview_url: 'https://actions.drafts.github.io/is-awesome'
})
@@ -185,6 +148,81 @@ describe('Deployment', () => {
artifactExchangeScope.done()
})
it('reports errors with a failed 500 in a deployment', async () => {
process.env.GITHUB_SHA = 'build-version'
const artifactExchangeScope = nock(`http://my-url`)
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA
})
.reply(500, { message: 'oh no' })
// Create the deployment
const deployment = new Deployment()
await expect(deployment.create()).rejects.toEqual(
new Error(
`Failed to create deployment (status: 500) with build version ${process.env.GITHUB_SHA}. Server error, is githubstatus.com reporting a Pages outage? Please re-run the deployment at a later time.`
)
)
artifactExchangeScope.done()
createDeploymentScope.done()
})
it('reports errors with an unexpected 403 during deployment', async () => {
process.env.GITHUB_SHA = 'build-version'
const artifactExchangeScope = nock(`http://my-url`)
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA
})
.reply(403, { message: 'You are forbidden' })
// Create the deployment
const deployment = new Deployment()
await expect(deployment.create()).rejects.toEqual(
new Error(
`Failed to create deployment (status: 403) with build version ${process.env.GITHUB_SHA}. Ensure GITHUB_TOKEN has permission "pages: write".`
)
)
artifactExchangeScope.done()
createDeploymentScope.done()
})
it('reports errors with an unexpected 404 during deployment', async () => {
process.env.GITHUB_SHA = 'build-version'
const artifactExchangeScope = nock(`http://my-url`)
.get('/_apis/pipelines/workflows/123/artifacts?api-version=6.0-preview')
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA
})
.reply(404, { message: 'Not found' })
// Create the deployment
const deployment = new Deployment()
await expect(deployment.create()).rejects.toEqual(
new Error(
`Failed to create deployment (status: 404) with build version ${process.env.GITHUB_SHA}. Ensure GitHub Pages has been enabled: https://github.com/actions/is-awesome/settings/pages`
)
)
artifactExchangeScope.done()
createDeploymentScope.done()
})
it('reports errors with failed deployments', async () => {
process.env.GITHUB_SHA = 'invalid-build-version'
const artifactExchangeScope = nock(`http://my-url`)
@@ -192,7 +230,7 @@ describe('Deployment', () => {
.reply(200, { value: [{ url: 'https://invalid-artifact.com', name: 'github-pages' }] })
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://invalid-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA
})
@@ -225,18 +263,18 @@ describe('Deployment', () => {
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})
const deploymentStatusScope = nock('https://api.github.com')
.get(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`)
.get(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`)
.reply(200, {
status: 'succeed'
})
@@ -263,6 +301,56 @@ describe('Deployment', () => {
createDeploymentScope.done()
deploymentStatusScope.done()
})
it('fails check when no deployment is found', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
const deployment = new Deployment()
await deployment.check()
expect(core.setFailed).toBeCalledWith('Deployment not found.')
})
it('exits early when deployment is not in progress', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
const artifactExchangeScope = 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' }
]
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
core.GetInput = jest.fn(input => {
switch (input) {
case 'timeout':
return 10 * 1000
case 'reporting_interval':
return 0
}
})
const deployment = new Deployment()
await deployment.create(fakeJwt)
deployment.deploymentInfo.pending = false
await deployment.check()
expect(core.setFailed).toBeCalledWith('Unable to get deployment status.')
artifactExchangeScope.done()
createDeploymentScope.done()
})
})
describe('#cancel', () => {
@@ -279,18 +367,18 @@ describe('Deployment', () => {
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment`, {
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/status/${process.env.GITHUB_SHA}`,
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})
const cancelDeploymentScope = nock('https://api.github.com')
.put(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployment/cancel/${process.env.GITHUB_SHA}`)
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}/cancel`)
.reply(200, {})
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
@@ -308,5 +396,62 @@ describe('Deployment', () => {
createDeploymentScope.done()
cancelDeploymentScope.done()
})
it('can exit if a pages deployment was not created and none need to be cancelled', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
// Create the deployment
const deployment = new Deployment()
// Cancel it
await deployment.cancel()
expect(core.debug).toHaveBeenCalledWith('all variables are set')
expect(core.debug).toHaveBeenCalledWith(`No deployment to cancel`)
})
it('catches an error when trying to cancel a deployment', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
const artifactExchangeScope = 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' }
]
})
const createDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments`, {
artifact_url: 'https://fake-artifact.com&%24expand=SignedContent',
pages_build_version: process.env.GITHUB_SHA,
oidc_token: fakeJwt
})
.reply(200, {
status_url: `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}`,
page_url: 'https://actions.github.io/is-awesome'
})
// nock will throw an error every time it tries to cancel the deployment
const cancelDeploymentScope = nock('https://api.github.com')
.post(`/repos/${process.env.GITHUB_REPOSITORY}/pages/deployments/${process.env.GITHUB_SHA}/cancel`)
.reply(500, {})
core.getIDToken = jest.fn().mockResolvedValue(fakeJwt)
// Create the deployment
const deployment = new Deployment()
await deployment.create(fakeJwt)
// Cancel it
await deployment.cancel()
expect(core.error).toHaveBeenCalledWith(`Canceling Pages deployment failed`, expect.anything())
artifactExchangeScope.done()
createDeploymentScope.done()
cancelDeploymentScope.done()
})
})
})

View File

@@ -4,8 +4,8 @@
const core = require('@actions/core')
const { Deployment } = require('./deployment')
const getContext = require('./context')
const { Deployment } = require('./internal/deployment')
const getContext = require('./internal/context')
const deployment = new Deployment()
@@ -48,9 +48,4 @@ process.on('SIGINT', cancelHandler)
process.on('SIGTERM', cancelHandler)
// Main
const emitTelemetry = core.getInput('emit_telemetry')
if (emitTelemetry === 'true') {
// For compatibility, treat the use of this deprecated input as a no-op
} else {
main()
}
main()

View File

@@ -113,7 +113,7 @@ async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, i
core.info(`Creating Pages deployment with payload:\n${JSON.stringify(payload, null, '\t')}`)
try {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployment', {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
...payload
@@ -131,7 +131,7 @@ async function getPagesDeploymentStatus({ githubToken, deploymentId }) {
core.info('Getting Pages deployment status...')
try {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployment/status/{deploymentId}', {
const response = await octokit.request('GET /repos/{owner}/{repo}/pages/deployments/{deploymentId}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId
@@ -149,7 +149,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {
core.info('Canceling Pages deployment...')
try {
const response = await octokit.request('PUT /repos/{owner}/{repo}/pages/deployment/cancel/{deploymentId}', {
const response = await octokit.request('POST /repos/{owner}/{repo}/pages/deployments/{deploymentId}/cancel', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
deploymentId

View File

@@ -98,6 +98,7 @@ class Deployment {
}
throw new Error(errorMessage)
} else {
// istanbul ignore next
throw error
}
}
@@ -202,6 +203,7 @@ class Deployment {
async cancel() {
// Don't attempt to cancel if no deployment was created
if (!this.deploymentInfo || this.deploymentInfo.pending !== true) {
core.debug('No deployment to cancel')
return
}