diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md new file mode 100644 index 00000000..01b642d0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -0,0 +1,27 @@ +--- +name: Bug Report +about: Create a bug report to help us improve the action. + +--- + +**Describe the bug** + +> Please provide a clear and concise description of what the bug is. + +**Reproduce** + +> Steps to reproduce the behavior. + + +**Expected behavior** + +> Please provide a clear and concise description of what you expected to happen. + +**Screenshots** + +> If applicable, add screenshots to help explain your problem. + + +**Additional Comments** + +> Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md new file mode 100644 index 00000000..52e7c09c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -0,0 +1,17 @@ +--- +name: Feature Request +about: If you'd like to make a suggestion please fill out the form below. + +--- + +**Is your feature request related to a problem? Please describe.** + +> Please provide a clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** + +> Please provide a clear and concise description of what you want to happen. + +**Additional Comments** + +> Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..94d2cd7c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +**Description** +> Provide a description of what your changes do. + +**Testing Instructions** +> Give us step by step instructions on how to test your changes. + +**Additional Notes** +> Anything else that will help us test the pull request. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9da5d881 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:10 + +LABEL "com.github.actions.name"="Deploy to Github Pages" +LABEL "com.github.actions.description"="Runs an optional build command and then pushes the branch to gh-pages." +LABEL "com.github.actions.icon"="github" +LABEL "com.github.actions.color"="#192022" + +LABEL "repository"="http://github.com/JamesIves/gh-pages-github-action" +LABEL "homepage"="http://github.com/JamesIves/gh-pages-gh-action" +LABEL "maintainer"="James Ives " + +ADD entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 00000000..933ba5b6 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Github Pages Deploy Action :github: + +This Github action will handle the building and deploying process of your project to Github pages. It can be configured to upload your production ready code into any branch you'd like, including `gh-pages` and `docs`. + +## Getting Started :airplane: +Before you get started you must first create a fresh branch where the action will deploy the files to. + +```git +git checkout --orphan gh-pages +git push origin +``` + +Once setup you can then include the script in your workflow to trigger on any built in event that Github supports. + +``` +action "Deploy to gh-pages" { + uses = "./action" + env = { + BUILD_SCRIPT = "npm install && npm run-script build" + BRANCH = "gh-pages" + FOLDER = "build" + COMMIT_EMAIL = "iam@jamesiv.es" + COMMIT_NAME = "James Ives" + } + secrets = ["GITHUB_TOKEN"] +} +``` + +## Configuration 📁 + +The `env` portion of the workflow must be configured before the action will work. Below you'll find a description of each one does. + +| Key | Value Information | Required | +| ------------- | ------------- | ------------- | +| `BUILD_SCRIPT` | If you require a build script to compile your code prior to pushing it you can add the script here. The Docker container which powers the action runs Node. | **No** | +| `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | **Yes** | +| `FOLDER` | The folder in your repository that you want to deploy. If your build script compiles into a directory named `build` you'd put it in here. | **Yes** | +| `COMMIT_NAME` | Used to sign the commit, this should be your name. | **No** | +| `COMMIT_EMAIL` | Used to sign the commit, this should be your email. | **No** | \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..630010d4 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/sh -l +if [ -z "$BRANCH" ] +then + echo "Which branch should this push to?" + exit 1 +fi + +if [ -z "$FOLDER" ] +then + echo "Which folder should this push to?" +fi + +# Installs Git. +apt-get update && \ +apt-get install -y git && \ + +# Re-directs to the the Github workspace. +cd $GITHUB_WORKSPACE && \ + +# Configures Git and checks out the base branch. +git config --global user.email "${COMMIT_EMAIL:-gh-pages-deploy@jives.dev}" && \ +git config --global user.name "${COMMIT_NAME:-Github Pages Deploy}" && \ +git checkout master && \ +git push $GITHUB_REPOSITORY $BRANCH:$BRANCH + +# Builds the project. +npm install && \ +npm run-script build && \ + +# Commits the data to Github. +git add -f $FOLDER && +git commit -m "Deploying $(date +"%T")" && \ +git push origin `git subtree split --prefix $FOLDER master`:$BRANCH --force +