A GitHub action to deploy preview environments for static apps using GitHub Pages.
This action expects you to checkout and build your static assets. After that, it will run next steps:
- Publish the contents from the folder of your choice into a branch where you should have configured GitHub Pages to be served.
- Use the branch name to create a sub-folder with your contents. That way, if your repository is
my-org/my-repo, you will be able to access the preview env in https://my-org.github.io/my-repo/main - If you run this action during
pull_requestorpull_request_targetevents: publish a comment after the preview env is ready, with the URL from previous step.
name: Build and Deploy
on:
pull_request: null
jobs:
build-and-deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install and Build
run: |
npm install
npm run build
- name: Deploy
uses: shlinkio/[email protected]
with:
branch: gh-pages # The branch from where the GitHub Pages are served (defaults to preview-env)
folder: build # The folder where the artifacts to publish are (defaults to the project root)| Param | Description | Required |
|---|---|---|
branch |
The name of the branch where GitHub Pages are getting served. Defaults to preview-env. |
No |
folder |
The folder including the static contents to deploy. Defaults to the project root. | No |
- Every deployment generates a sub-folder. This action does not take care of deleting them.
- Some static pages or statically generated pages expect to be served from the root of the domain. This action deploys on a sub-folder, so you may need extra steps to ensure your app works once deployed.