-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# CHANGELOG | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). | ||
|
||
## [1.0.0] - 2021-08-29 | ||
### Added | ||
* First release | ||
|
||
### Changed | ||
* *Nothing* | ||
|
||
### Deprecated | ||
* *Nothing* | ||
|
||
### Removed | ||
* *Nothing* | ||
|
||
### Fixed | ||
* *Nothing* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
# deploy-preview-action | ||
A github action to deploy preview environments for static apps using GitHub Pages | ||
# Deploy Preview Action | ||
|
||
A GitHub action to deploy preview environments for static apps using GitHub Pages. | ||
|
||
## How it works | ||
|
||
This action expects you to checkout and build your static assets. After that, it will run next steps: | ||
|
||
* Generate a unique slug from the branch name plus current date. For example, if your branch is `Update-landing-page`, it will generate a slug like `2021-05-08-update-landing-page`. | ||
* Publish the contents from the folder of your choice into a branch where you should have configured GitHub Pages to be served. | ||
* Use the slug generated in first step 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/2021-05-08-update-landing-page | ||
* If you run this action during `pull_request` or `pull_request_target` events: publish a comment after the preview env is ready, with the URL from previous step. | ||
|
||
## Usage | ||
|
||
```yaml | ||
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/deploy-preview-action@v1 | ||
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) | ||
``` | ||
## Configuration | ||
| 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 | | ||
|
||
## Considerations | ||
|
||
* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Deploy preview | ||
description: Deploy preview environments for static apps using GitHub Pages | ||
|
||
inputs: | ||
branch: | ||
description: The branch from where the GitHub Pages are served (defaults to preview-env) | ||
required: true | ||
default: 'preview-env' | ||
folder: | ||
description: The folder where the artifacts to publish are (defaults to the project root) | ||
required: true | ||
default: '.' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Generate slug | ||
id: generate_slug | ||
run: echo "##[set-output name=slug;]$(echo ${GITHUB_HEAD_REF#refs/heads/} | sed -r 's/[~\^]+//g' | sed -r 's/[^a-zA-Z0-9]+/-/g' | sed -r 's/^-+\|-+$//g' | tr A-Z a-z)" | ||
shell: bash | ||
- name: Determine base URL | ||
id: determine_base_url | ||
run: echo "##[set-output name=base_url;]$(echo $GITHUB_REPOSITORY | sed 's/\//.github.io\//')" | ||
shell: bash | ||
- name: Deploy | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: ${{ inputs.branch }} | ||
folder: ${{ inputs.folder }} | ||
target-folder: ${{ steps.generate_slug.outputs.slug }} | ||
- name: Publish env | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: Preview environment | ||
message: | | ||
## Preview environment | ||
https://${{ steps.determine_base_url.outputs.base_url }}/${{ steps.generate_slug.outputs.slug }}/ |