mirror of
https://github.com/actions/deploy-pages.git
synced 2026-03-29 01:14:53 +00:00
Compare commits
5 Commits
v4.0.5
...
error-coun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7b5c1034e | ||
|
|
b4d15f6490 | ||
|
|
c883148031 | ||
|
|
b1a18fc1bd | ||
|
|
a378718509 |
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@@ -4,14 +4,8 @@ updates:
|
|||||||
directory: '/'
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'weekly'
|
interval: 'weekly'
|
||||||
groups:
|
|
||||||
non-breaking-changes:
|
|
||||||
update-types: [minor, patch]
|
|
||||||
|
|
||||||
- package-ecosystem: 'npm'
|
- package-ecosystem: 'npm'
|
||||||
directory: '/'
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'weekly'
|
interval: 'weekly'
|
||||||
groups:
|
|
||||||
non-breaking-changes:
|
|
||||||
update-types: [minor, patch]
|
|
||||||
|
|||||||
2
.github/release-drafter.yml
vendored
2
.github/release-drafter.yml
vendored
@@ -10,7 +10,7 @@ template: |
|
|||||||
|
|
||||||
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/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.
|
||||||
|
|
||||||
:warning: For use with products other than GitHub.com, such as GitHub Enterprise Server, please consult the [compatibility table](https://github.com/$OWNER/$REPOSITORY/#compatibility).
|
:warning: For use with products other than GitHub.com, such as GitHub Enterprise Server, please consult the [compatibility table](https://github.com/$OWNER/$REPOSITORY/#compatibilty).
|
||||||
categories:
|
categories:
|
||||||
- title: '🚀 Features'
|
- title: '🚀 Features'
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -22,10 +22,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node.JS
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# If index.js was different than expected, upload the expected version as an artifact
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v3
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
|
|||||||
4
.github/workflows/check-formatting.yml
vendored
4
.github/workflows/check-formatting.yml
vendored
@@ -19,10 +19,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node.JS
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|||||||
4
.github/workflows/check-linter.yml
vendored
4
.github/workflows/check-linter.yml
vendored
@@ -19,10 +19,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node.JS
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|||||||
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -38,11 +38,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v3
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -67,4 +67,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v3
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
2
.github/workflows/draft-release.yml
vendored
2
.github/workflows/draft-release.yml
vendored
@@ -11,6 +11,6 @@ jobs:
|
|||||||
draft-release:
|
draft-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
|
- uses: release-drafter/release-drafter@569eb7ee3a85817ab916c8f8ff03a5bd96c9c83e # v5.23.0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
4
.github/workflows/rebuild-dependabot-prs.yml
vendored
4
.github/workflows/rebuild-dependabot-prs.yml
vendored
@@ -22,12 +22,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.PAGES_AUTOMATION_PAT }}
|
token: ${{ secrets.PAGES_AUTOMATION_PAT }}
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node.JS
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
id: update-major-tag
|
id: update-major-tag
|
||||||
uses: actions/publish-action@v0.3.0
|
uses: actions/publish-action@v0.2.2
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -14,10 +14,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node.JS
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
20.10.0
|
18.9.0
|
||||||
|
|||||||
28
README.md
28
README.md
@@ -6,11 +6,11 @@ This action is used to deploy [Actions artifacts][artifacts] to [GitHub Pages](h
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See [action.yml](action.yml) for the various `inputs` this action supports (or [below](#inputs-📥)).
|
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.
|
For examples that make use of this action, check out our [starter-workflows][starter-workflows] in a variety of frameworks.
|
||||||
|
|
||||||
This action deploys a Pages site previously uploaded as an artifact (e.g. 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:
|
We recommend this action to be used in a dedicated job:
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
|
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action
|
||||||
```
|
```
|
||||||
|
|
||||||
### Inputs 📥
|
### Inputs 📥
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
| `token` | `true` | `${{ github.token }}` | The GitHub token used to create an authenticated client - Provided for you by default! |
|
| `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) |
|
| `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) |
|
| `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 reports (default: 5 seconds) |
|
| `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 |
|
| `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!) |
|
| `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!) |
|
||||||
|
|
||||||
@@ -67,11 +67,15 @@ jobs:
|
|||||||
| -------- | ----------- |
|
| -------- | ----------- |
|
||||||
| `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. |
|
| `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
|
## Security Considerations
|
||||||
|
|
||||||
There are a few important considerations to be aware of:
|
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. See [`actions/upload-pages-artifact`][upload-pages-artifact] for more information about the format of the artifact we expect.
|
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:
|
2. The job that executes the deployment must at minimum have the following permissions:
|
||||||
- `pages: write`
|
- `pages: write`
|
||||||
@@ -85,18 +89,16 @@ There are a few important considerations to be aware of:
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
This action is primarily designed for use with GitHub.com's Actions workflows and Pages deployments. However, certain releases should also be compatible with GitHub Enterprise Server (GHES) `3.7` and above.
|
This action is primarily design for use with GitHub.com's Actions workflows and Pages deployments. However, certain releases should also be compatible with GitHub Enterprise Server (GHES) `3.7` and above.
|
||||||
|
|
||||||
| Release | GHES Compatibility |
|
| Release | GHES Compatibility |
|
||||||
|:---|:---|
|
|:---|:---|
|
||||||
| [`v4`](https://github.com/actions/deploy-pages/releases/tag/v4) | :warning: Incompatible at this time |
|
| [`v2`](https://github.com/actions/deploy-pages/releases/tag/v2) | 🛑 Incompatible. Anticipating compatibility with `>= 3.9`. |
|
||||||
| [`v3`](https://github.com/actions/deploy-pages/releases/tag/v3) | `>= 3.9` |
|
| [`v2.0.1`](https://github.com/actions/deploy-pages/releases/tag/v2.0.1) | 🛑 Incompatible. Anticipating compatibility with `>= 3.9`. |
|
||||||
| `v3.x.x` | `>= 3.9` |
|
| [`v2.0.0`](https://github.com/actions/deploy-pages/releases/tag/v2.0.0) | 🛑 Incompatible. Anticipating compatibility with `>= 3.9`. |
|
||||||
| [`v2`](https://github.com/actions/deploy-pages/releases/tag/v2) | `>= 3.9` |
|
|
||||||
| `v2.x.x` | `>= 3.9` |
|
|
||||||
| [`v1`](https://github.com/actions/deploy-pages/releases/tag/v1) | `>= 3.7` |
|
| [`v1`](https://github.com/actions/deploy-pages/releases/tag/v1) | `>= 3.7` |
|
||||||
| [`v1.2.8`](https://github.com/actions/deploy-pages/releases/tag/v1.2.8) | `>= 3.7` |
|
| [`v1.2.8`](https://github.com/actions/deploy-pages/releases/tag/v1.2.8) | `>= 3.7` |
|
||||||
| [`v1.2.7`](https://github.com/actions/deploy-pages/releases/tag/v1.2.7) | :warning: `>= 3.9` [Incompatible with prior versions!](https://github.com/actions/deploy-pages/issues/137) |
|
| [`v1.2.7`](https://github.com/actions/deploy-pages/releases/tag/v1.2.7) | :warning: [Incompatible](https://github.com/actions/deploy-pages/issues/137). Anticipating compatibility with `>= 3.9`. |
|
||||||
| [`v1.2.6`](https://github.com/actions/deploy-pages/releases/tag/v1.2.6) | `>= 3.7` |
|
| [`v1.2.6`](https://github.com/actions/deploy-pages/releases/tag/v1.2.6) | `>= 3.7` |
|
||||||
| `v1.x.x` | `>= 3.7` |
|
| `v1.x.x` | `>= 3.7` |
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ In order to release a new version of this Action:
|
|||||||
|
|
||||||
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:
|
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 major version tag such as `v1`.
|
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].
|
⚠️ Environment approval is required. Check the [Release workflow run list][release-workflow-runs].
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: 'Deploy GitHub Pages site'
|
|||||||
description: 'A GitHub Action to deploy an artifact as a GitHub Pages site'
|
description: 'A GitHub Action to deploy an artifact as a GitHub Pages site'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
inputs:
|
inputs:
|
||||||
token:
|
token:
|
||||||
|
|||||||
@@ -1 +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: 80.84%"><title>Coverage: 80.84%</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="#dfb317"/><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">80.84%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">80.84%</text></g></svg>
|
<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: 80.18%"><title>Coverage: 80.18%</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="#dfb317"/><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">80.18%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">80.18%</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
144616
dist/index.js
generated
vendored
144616
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2706
dist/licenses.txt
generated
vendored
2706
dist/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
9035
package-lock.json
generated
9035
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@@ -4,22 +4,21 @@
|
|||||||
"description": "Deploy an actions artifact to GitHub Pages",
|
"description": "Deploy an actions artifact to GitHub Pages",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^2.1.3",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/http-client": "^2.1.0",
|
||||||
"@octokit/request-error": "^5.0.1",
|
"@octokit/request-error": "^4.0.1",
|
||||||
"http-status-messages": "^1.1.0"
|
"http-status-messages": "^1.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.36.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.42.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
"eslint-plugin-github": "^4.10.1",
|
"eslint-plugin-github": "^4.8.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.5.0",
|
||||||
"make-coverage-badge": "^1.2.0",
|
"nock": "^13.3.1",
|
||||||
"nock": "^13.5.3",
|
"prettier": "^2.8.8",
|
||||||
"prettier": "^3.2.5",
|
"make-coverage-badge": "^1.2.0"
|
||||||
"undici": "^6.6.2"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"all": "npm run format && npm run lint && npm run prepare && npm run test && npm run coverage-badge",
|
"all": "npm run format && npm run lint && npm run prepare && npm run test && npm run coverage-badge",
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ const path = require('path')
|
|||||||
|
|
||||||
describe('with all environment variables set', () => {
|
describe('with all environment variables set', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
process.env.ACTIONS_RUNTIME_URL = 'http://my-url'
|
||||||
process.env.GITHUB_RUN_ID = '123'
|
process.env.GITHUB_RUN_ID = '123'
|
||||||
|
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
|
||||||
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
process.env.GITHUB_REPOSITORY = 'actions/is-awesome'
|
||||||
process.env.GITHUB_TOKEN = 'gha-token'
|
process.env.GITHUB_TOKEN = 'gha-token'
|
||||||
process.env.GITHUB_SHA = '123abc'
|
process.env.GITHUB_SHA = '123abc'
|
||||||
@@ -24,7 +26,7 @@ describe('with all environment variables set', () => {
|
|||||||
|
|
||||||
describe('with variables missing', () => {
|
describe('with variables missing', () => {
|
||||||
it('execution fails if there are missing variables', done => {
|
it('execution fails if there are missing variables', done => {
|
||||||
delete process.env.GITHUB_RUN_ID
|
delete process.env.ACTIONS_RUNTIME_URL
|
||||||
const ip = path.join(__dirname, '../index.js')
|
const ip = path.join(__dirname, '../index.js')
|
||||||
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
|
cp.exec(`node ${ip}`, { env: process.env }, (err, stdout) => {
|
||||||
expect(stdout).toBe('')
|
expect(stdout).toBe('')
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,118 +1,119 @@
|
|||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const github = require('@actions/github')
|
const github = require('@actions/github')
|
||||||
const { DefaultArtifactClient } = require('@actions/artifact')
|
const hc = require('@actions/http-client')
|
||||||
const { RequestError } = require('@octokit/request-error')
|
const { RequestError } = require('@octokit/request-error')
|
||||||
const HttpStatusMessages = require('http-status-messages')
|
const HttpStatusMessages = require('http-status-messages')
|
||||||
|
|
||||||
function wrapTwirpResponseLikeOctokit(twirpResponse, requestOptions) {
|
// All variables we need from the runtime are loaded here
|
||||||
|
const getContext = require('./context')
|
||||||
|
|
||||||
|
async function processRuntimeResponse(res, requestOptions) {
|
||||||
|
// Parse the response body as JSON
|
||||||
|
let obj = null
|
||||||
|
try {
|
||||||
|
const contents = await res.readBody()
|
||||||
|
if (contents && contents.length > 0) {
|
||||||
|
obj = JSON.parse(contents)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Invalid resource (contents not json); leaving resulting obj as null
|
||||||
|
}
|
||||||
|
|
||||||
// Specific response shape aligned with Octokit
|
// Specific response shape aligned with Octokit
|
||||||
const response = {
|
const response = {
|
||||||
url: requestOptions.url,
|
url: res.message?.url || requestOptions.url,
|
||||||
status: 200,
|
status: res.message?.statusCode || 0,
|
||||||
headers: {
|
headers: {
|
||||||
...requestOptions.headers
|
...res.message?.headers
|
||||||
},
|
},
|
||||||
data: twirpResponse
|
data: obj
|
||||||
}
|
|
||||||
return response
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forcibly throw errors for negative HTTP status codes!
|
||||||
|
// @actions/http-client doesn't do this by default.
|
||||||
// Mimic the errors thrown by Octokit for consistency.
|
// Mimic the errors thrown by Octokit for consistency.
|
||||||
function wrapTwirpErrorLikeOctokit(twirpError, requestOptions) {
|
if (response.status >= 400) {
|
||||||
const rawErrorMsg = twirpError?.message || twirpError?.toString() || ''
|
// Try to get an error message from the response body
|
||||||
const statusCodeMatch = rawErrorMsg.match(/Failed request: \((?<statusCode>\d+)\)/)
|
|
||||||
const statusCode = statusCodeMatch?.groups?.statusCode ?? 500
|
|
||||||
|
|
||||||
// Try to provide the best error message
|
|
||||||
const errorMsg =
|
const errorMsg =
|
||||||
rawErrorMsg ||
|
(typeof response.data === 'string' && response.data) ||
|
||||||
|
response.data?.error ||
|
||||||
|
response.data?.message ||
|
||||||
|
// Try the Node HTTP IncomingMessage's statusMessage property
|
||||||
|
res.message?.statusMessage ||
|
||||||
// Fallback to the HTTP status message based on the status code
|
// Fallback to the HTTP status message based on the status code
|
||||||
HttpStatusMessages[statusCode] ||
|
HttpStatusMessages[response.status] ||
|
||||||
// Or if the status code is unexpected...
|
// Or if the status code is unexpected...
|
||||||
`Unknown error (${statusCode})`
|
`Unknown error (${response.status})`
|
||||||
|
|
||||||
// RequestError is an Octokit-specific class
|
throw new RequestError(errorMsg, response.status, {
|
||||||
return new RequestError(errorMsg, statusCode, {
|
response,
|
||||||
response: {
|
|
||||||
url: requestOptions.url,
|
|
||||||
status: statusCode,
|
|
||||||
headers: {
|
|
||||||
...requestOptions.headers
|
|
||||||
},
|
|
||||||
data: rawErrorMsg ? { message: rawErrorMsg } : ''
|
|
||||||
},
|
|
||||||
request: requestOptions
|
request: requestOptions
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArtifactsServiceOrigin() {
|
return response
|
||||||
const resultsUrl = process.env.ACTIONS_RESULTS_URL
|
|
||||||
return resultsUrl ? new URL(resultsUrl).origin : ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getArtifactMetadata({ artifactName }) {
|
async function getSignedArtifactMetadata({ runtimeToken, workflowRunId, artifactName }) {
|
||||||
const artifactClient = new DefaultArtifactClient()
|
const { runTimeUrl: RUNTIME_URL } = getContext()
|
||||||
|
const artifactExchangeUrl = `${RUNTIME_URL}_apis/pipelines/workflows/${workflowRunId}/artifacts?api-version=6.0-preview`
|
||||||
|
|
||||||
// Primarily for debugging purposes, accuracy is not critical
|
const httpClient = new hc.HttpClient()
|
||||||
|
let data = null
|
||||||
|
|
||||||
|
try {
|
||||||
|
const requestHeaders = {
|
||||||
|
accept: 'application/json',
|
||||||
|
authorization: `Bearer ${runtimeToken}`
|
||||||
|
}
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
url: `${getArtifactsServiceOrigin()}/twirp/github.actions.results.api.v1.ArtifactService/ListArtifacts`,
|
url: artifactExchangeUrl,
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json'
|
...requestHeaders
|
||||||
},
|
},
|
||||||
body: {}
|
body: null
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
core.info(`Artifact exchange URL: ${artifactExchangeUrl}`)
|
||||||
core.info(`Fetching artifact metadata for "${artifactName}" in this workflow run`)
|
const res = await httpClient.get(artifactExchangeUrl, requestHeaders)
|
||||||
|
|
||||||
let response
|
// May throw a RequestError (HttpError)
|
||||||
try {
|
const response = await processRuntimeResponse(res, requestOptions)
|
||||||
const twirpResponse = await artifactClient.listArtifacts()
|
|
||||||
response = wrapTwirpResponseLikeOctokit(twirpResponse, requestOptions)
|
data = response.data
|
||||||
} catch (twirpError) {
|
core.debug(JSON.stringify(data))
|
||||||
core.error('Listing artifact metadata failed', twirpError)
|
} catch (error) {
|
||||||
const octokitError = wrapTwirpErrorLikeOctokit(twirpError, requestOptions)
|
core.error('Getting signed artifact URL failed', error)
|
||||||
throw octokitError
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
const filteredArtifacts = response.data.artifacts.filter(artifact => artifact.name === artifactName)
|
const artifact = data?.value?.find(artifact => artifact.name === artifactName)
|
||||||
|
const artifactRawUrl = artifact?.url
|
||||||
const artifactCount = filteredArtifacts.length
|
if (!artifactRawUrl) {
|
||||||
core.debug(`List artifact count: ${artifactCount}`)
|
|
||||||
|
|
||||||
if (artifactCount === 0) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No artifacts named "${artifactName}" were found for this workflow run. Ensure artifacts are uploaded with actions/upload-artifact@v4 or later.`
|
'No uploaded artifact was found! Please check if there are any errors at build step, or uploaded artifact name is correct.'
|
||||||
)
|
|
||||||
} else if (artifactCount > 1) {
|
|
||||||
throw new Error(
|
|
||||||
`Multiple artifacts named "${artifactName}" were unexpectedly found for this workflow run. Artifact count is ${artifactCount}.`
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const artifact = filteredArtifacts[0]
|
const signedArtifactUrl = `${artifactRawUrl}&%24expand=SignedContent`
|
||||||
core.debug(`Artifact: ${JSON.stringify(artifact)}`)
|
|
||||||
|
|
||||||
if (!artifact.size) {
|
const artifactSize = artifact?.size
|
||||||
|
if (!artifactSize) {
|
||||||
core.warning('Artifact size was not found. Unable to verify if artifact size exceeds the allowed size.')
|
core.warning('Artifact size was not found. Unable to verify if artifact size exceeds the allowed size.')
|
||||||
}
|
}
|
||||||
|
|
||||||
return artifact
|
return {
|
||||||
} catch (error) {
|
url: signedArtifactUrl,
|
||||||
core.error(
|
size: artifactSize
|
||||||
'Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages, or Actions? Please re-run the deployment at a later time.',
|
|
||||||
error
|
|
||||||
)
|
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPagesDeployment({ githubToken, artifactId, buildVersion, idToken, isPreview = false }) {
|
async function createPagesDeployment({ githubToken, artifactUrl, buildVersion, idToken, isPreview = false }) {
|
||||||
const octokit = github.getOctokit(githubToken)
|
const octokit = github.getOctokit(githubToken)
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
artifact_id: artifactId,
|
artifact_url: artifactUrl,
|
||||||
pages_build_version: buildVersion,
|
pages_build_version: buildVersion,
|
||||||
oidc_token: idToken
|
oidc_token: idToken
|
||||||
}
|
}
|
||||||
@@ -172,7 +173,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getArtifactMetadata,
|
getSignedArtifactMetadata,
|
||||||
createPagesDeployment,
|
createPagesDeployment,
|
||||||
getPagesDeploymentStatus,
|
getPagesDeploymentStatus,
|
||||||
cancelPagesDeployment
|
cancelPagesDeployment
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ const core = require('@actions/core')
|
|||||||
// Load variables from Actions runtime
|
// Load variables from Actions runtime
|
||||||
function getRequiredVars() {
|
function getRequiredVars() {
|
||||||
return {
|
return {
|
||||||
|
runTimeUrl: process.env.ACTIONS_RUNTIME_URL,
|
||||||
workflowRun: process.env.GITHUB_RUN_ID,
|
workflowRun: process.env.GITHUB_RUN_ID,
|
||||||
|
runTimeToken: process.env.ACTIONS_RUNTIME_TOKEN,
|
||||||
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
||||||
buildVersion: process.env.GITHUB_SHA,
|
buildVersion: process.env.GITHUB_SHA,
|
||||||
buildActor: process.env.GITHUB_ACTOR,
|
buildActor: process.env.GITHUB_ACTOR,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const core = require('@actions/core')
|
|||||||
// All variables we need from the runtime are loaded here
|
// All variables we need from the runtime are loaded here
|
||||||
const getContext = require('./context')
|
const getContext = require('./context')
|
||||||
const {
|
const {
|
||||||
getArtifactMetadata,
|
getSignedArtifactMetadata,
|
||||||
createPagesDeployment,
|
createPagesDeployment,
|
||||||
getPagesDeploymentStatus,
|
getPagesDeploymentStatus,
|
||||||
cancelPagesDeployment
|
cancelPagesDeployment
|
||||||
@@ -17,7 +17,6 @@ const temporaryErrorStatus = {
|
|||||||
|
|
||||||
const finalErrorStatus = {
|
const finalErrorStatus = {
|
||||||
deployment_failed: 'Deployment failed, try again later.',
|
deployment_failed: 'Deployment failed, try again later.',
|
||||||
deployment_perms_error: 'Deployment failed. Please ensure that the file permissions are correct.',
|
|
||||||
deployment_content_failed:
|
deployment_content_failed:
|
||||||
'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.',
|
'Artifact could not be deployed. Please ensure the content does not contain any hard links, symlinks and total size is less than 10GB.',
|
||||||
deployment_cancelled: 'Deployment cancelled.',
|
deployment_cancelled: 'Deployment cancelled.',
|
||||||
@@ -31,7 +30,9 @@ const SIZE_LIMIT_DESCRIPTION = '1 GB'
|
|||||||
class Deployment {
|
class Deployment {
|
||||||
constructor() {
|
constructor() {
|
||||||
const context = getContext()
|
const context = getContext()
|
||||||
|
this.runTimeUrl = context.runTimeUrl
|
||||||
this.repositoryNwo = context.repositoryNwo
|
this.repositoryNwo = context.repositoryNwo
|
||||||
|
this.runTimeToken = context.runTimeToken
|
||||||
this.buildVersion = context.buildVersion
|
this.buildVersion = context.buildVersion
|
||||||
this.buildActor = context.buildActor
|
this.buildActor = context.buildActor
|
||||||
this.actionsId = context.actionsId
|
this.actionsId = context.actionsId
|
||||||
@@ -44,26 +45,41 @@ class Deployment {
|
|||||||
this.isPreview = context.isPreview === true
|
this.isPreview = context.isPreview === true
|
||||||
this.timeout = MAX_TIMEOUT
|
this.timeout = MAX_TIMEOUT
|
||||||
this.startTime = null
|
this.startTime = null
|
||||||
|
this.maxErrorCount = null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call GitHub api to fetch artifacts matching the provided name and deploy to GitHub Pages
|
setOptionalUserInput() {
|
||||||
// by creating a deployment with that artifact id
|
const timeoutInput = Number(core.getInput('timeout'))
|
||||||
async create(idToken) {
|
if (timeoutInput > MAX_TIMEOUT) {
|
||||||
if (Number(core.getInput('timeout')) > MAX_TIMEOUT) {
|
|
||||||
core.warning(
|
core.warning(
|
||||||
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
`Warning: timeout value is greater than the allowed maximum - timeout set to the maximum of ${MAX_TIMEOUT} milliseconds.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeoutInput = Number(core.getInput('timeout'))
|
|
||||||
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
this.timeout = !timeoutInput || timeoutInput <= 0 ? MAX_TIMEOUT : Math.min(timeoutInput, MAX_TIMEOUT)
|
||||||
|
|
||||||
|
const maxErrorCountInput = Number(core.getInput('error_count'))
|
||||||
|
if (!maxErrorCountInput || maxErrorCountInput <= 0) {
|
||||||
|
core.warning('Invalid error_count value will be ignored. Please ensure the value is a positive integer.')
|
||||||
|
} else {
|
||||||
|
this.maxErrorCount = maxErrorCountInput
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
|
||||||
|
// by creating a deployment with that artifact
|
||||||
|
async create(idToken) {
|
||||||
try {
|
try {
|
||||||
|
this.setOptionalUserInput()
|
||||||
|
|
||||||
core.debug(`Actor: ${this.buildActor}`)
|
core.debug(`Actor: ${this.buildActor}`)
|
||||||
core.debug(`Action ID: ${this.actionsId}`)
|
core.debug(`Action ID: ${this.actionsId}`)
|
||||||
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
|
||||||
|
|
||||||
const artifactData = await getArtifactMetadata({ artifactName: this.artifactName })
|
const artifactData = await getSignedArtifactMetadata({
|
||||||
|
runtimeToken: this.runTimeToken,
|
||||||
|
workflowRunId: this.workflowRun,
|
||||||
|
artifactName: this.artifactName
|
||||||
|
})
|
||||||
|
|
||||||
if (artifactData?.size > ONE_GIGABYTE) {
|
if (artifactData?.size > ONE_GIGABYTE) {
|
||||||
core.warning(
|
core.warning(
|
||||||
@@ -73,7 +89,7 @@ class Deployment {
|
|||||||
|
|
||||||
const deployment = await createPagesDeployment({
|
const deployment = await createPagesDeployment({
|
||||||
githubToken: this.githubToken,
|
githubToken: this.githubToken,
|
||||||
artifactId: artifactData.id,
|
artifactUrl: artifactData.url,
|
||||||
buildVersion: this.buildVersion,
|
buildVersion: this.buildVersion,
|
||||||
idToken,
|
idToken,
|
||||||
isPreview: this.isPreview
|
isPreview: this.isPreview
|
||||||
@@ -96,12 +112,12 @@ class Deployment {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(error.stack)
|
core.error(error.stack)
|
||||||
|
|
||||||
|
// output raw error in debug mode.
|
||||||
|
core.debug(JSON.stringify(error))
|
||||||
|
|
||||||
// build customized error message based on server response
|
// build customized error message based on server response
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. `
|
let errorMessage = `Failed to create deployment (status: ${error.status}) with build version ${this.buildVersion}. `
|
||||||
if (error.response.headers['x-github-request-id']) {
|
|
||||||
errorMessage += ` Request ID ${error.response.headers['x-github-request-id']}`
|
|
||||||
}
|
|
||||||
if (error.status === 400) {
|
if (error.status === 400) {
|
||||||
errorMessage += `Responded with: ${error.message}`
|
errorMessage += `Responded with: ${error.message}`
|
||||||
} else if (error.status === 403) {
|
} else if (error.status === 403) {
|
||||||
@@ -140,7 +156,6 @@ class Deployment {
|
|||||||
|
|
||||||
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
const deploymentId = this.deploymentInfo.id || this.buildVersion
|
||||||
const reportingInterval = Number(core.getInput('reporting_interval'))
|
const reportingInterval = Number(core.getInput('reporting_interval'))
|
||||||
const maxErrorCount = Number(core.getInput('error_count'))
|
|
||||||
|
|
||||||
let errorCount = 0
|
let errorCount = 0
|
||||||
|
|
||||||
@@ -183,6 +198,9 @@ class Deployment {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(error.stack)
|
core.error(error.stack)
|
||||||
|
|
||||||
|
// output raw error in debug mode.
|
||||||
|
core.debug(JSON.stringify(error))
|
||||||
|
|
||||||
// build customized error message based on server response
|
// build customized error message based on server response
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
errorStatus = error.status || error.response.status
|
errorStatus = error.status || error.response.status
|
||||||
@@ -196,7 +214,7 @@ class Deployment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorCount >= maxErrorCount) {
|
if (errorCount >= this.maxErrorCount) {
|
||||||
core.error('Too many errors, aborting!')
|
core.error('Too many errors, aborting!')
|
||||||
core.setFailed('Failed with status code: ' + errorStatus)
|
core.setFailed('Failed with status code: ' + errorStatus)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user