2023-04-13 23:08:45 +01:00
# deploy-pages 🚀
2023-04-18 00:32:50 -05:00
[](https://github.com/actions/deploy-pages/releases/latest) [](https://github.com/actions/deploy-pages/actions/workflows/check-linter.yml) [](https://github.com/actions/deploy-pages/actions/workflows/check-formatting.yml) [](https://github.com/actions/deploy-pages/actions/workflows/test.yml)  [](https://github.com/actions/deploy-pages/actions/workflows/check-dist.yml) [](https://github.com/actions/deploy-pages/actions/workflows/codeql-analysis.yml)
2021-12-13 23:03:09 -05:00
2023-04-13 23:26:36 +01:00
This action is used to deploy [Actions artifacts][artifacts] to [GitHub Pages ](https://pages.github.com/ ).
2021-12-13 23:03:09 -05:00
2022-07-26 10:47:31 -07:00
## Usage
2021-12-13 23:03:09 -05:00
2023-07-27 22:30:35 -07:00
See [action.yml ](action.yml ) for the various `inputs` this action supports (or [below ](#inputs-📥 )).
2021-12-13 23:03:09 -05:00
2022-07-26 11:11:30 -07:00
For examples that make use of this action, check out our [starter-workflows][starter-workflows] in a variety of frameworks.
2021-12-13 23:03:09 -05:00
2023-07-27 22:30:35 -07:00
This action deploys a Pages site previously uploaded as an artifact (e.g. using [`actions/upload-pages-artifact` ][upload-pages-artifact]).
2022-07-26 10:47:31 -07:00
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
2023-12-19 10:03:19 -05:00
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
2022-07-26 10:47:31 -07:00
```
2023-04-17 23:35:32 -05:00
### Inputs 📥
2023-04-13 23:23:56 +01:00
| 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) |
2023-12-07 16:08:41 +05:30
| `reporting_interval` | `false` | `"5000"` | Time in milliseconds between two deployment status reports (default: 5 seconds) |
2023-04-13 23:23:56 +01:00
| `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!) |
2023-04-17 23:35:32 -05:00
### Outputs 📤
2023-04-13 23:23:56 +01:00
| Output | Description |
| ------ | ----------- |
| `page_url` | The URL of the deployed Pages site |
2023-04-17 23:35:32 -05:00
### 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. |
2023-04-13 23:26:36 +01:00
## Security Considerations
2022-07-26 10:47:31 -07:00
There are a few important considerations to be aware of:
2023-07-27 22:30:35 -07:00
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.
2022-07-26 10:47:31 -07:00
2022-07-26 11:14:35 -07:00
2. The job that executes the deployment must at minimum have the following permissions:
2022-07-26 10:47:31 -07:00
- `pages: write`
- `id-token: write`
2022-07-26 11:11:16 -07:00
3. The deployment should target the `github-pages` environment (you may use a different environment name if needed, but this is not recommended.)
2022-07-26 10:47:31 -07:00
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
2023-04-17 23:37:32 -05:00
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).
2022-07-26 11:09:31 -07:00
2023-05-15 17:49:07 -05:00
## Compatibility
2023-12-07 16:08:41 +05:30
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.
2023-05-15 17:49:07 -05:00
| Release | GHES Compatibility |
|:---|:---|
2023-12-19 12:15:02 -05:00
| [`v4` ](https://github.com/actions/deploy-pages/releases/tag/v4 ) | :warning: Incompatible at this time |
2023-12-04 19:42:16 -06:00
| [`v3` ](https://github.com/actions/deploy-pages/releases/tag/v3 ) | `>= 3.9` |
| `v3.x.x` | `>= 3.9` |
2023-07-20 00:17:35 -05:00
| [`v2` ](https://github.com/actions/deploy-pages/releases/tag/v2 ) | `>= 3.9` |
| `v2.x.x` | `>= 3.9` |
2023-05-15 17:49:07 -05:00
| [`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` |
2023-07-20 00:18:22 -05:00
| [`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 ) |
2023-05-15 17:49:07 -05:00
| [`v1.2.6` ](https://github.com/actions/deploy-pages/releases/tag/v1.2.6 ) | `>= 3.7` |
| `v1.x.x` | `>= 3.7` |
2023-04-13 23:26:36 +01:00
## Release Instructions
2022-08-24 10:53:23 -07:00
In order to release a new version of this Action:
2022-09-19 10:53:48 -05:00
1. Locate the semantic version of the [upcoming release][release-list] (a draft is maintained by the [`draft-release` workflow][draft-release]).
2022-08-24 10:53:23 -07:00
2022-09-19 10:53:48 -05:00
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:
2023-12-07 16:08:41 +05:30
3. After publishing the release, the [`release` workflow][release] will automatically run to create/update the corresponding major version tag such as `v1` .
2022-08-24 10:53:23 -07:00
⚠️ Environment approval is required. Check the [Release workflow run list][release-workflow-runs].
2022-07-26 10:47:31 -07:00
## License
2021-12-13 23:03:09 -05:00
The scripts and documentation in this project are released under the [MIT License ](LICENSE ).
2022-07-26 10:47:31 -07:00
<!-- 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
2022-08-10 14:01:18 -05:00
[environment-protection]: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment -protection-rules
2022-09-19 10:53:48 -05:00
[release-list]: https://github.com/actions/deploy-pages/releases
[draft-release]: .github/workflows/draft-release.yml
2022-08-24 10:54:29 -07:00
[release]: .github/workflows/release.yml
2022-09-19 10:53:48 -05:00
[release-workflow-runs]: https://github.com/actions/deploy-pages/actions/workflows/release.yml