Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikoval committed Dec 17, 2019
0 parents commit 69b82c4
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:latest
ENV RUBYGEMS_VERSION=2.7.0
# Set default locale for the environment
ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

LABEL "com.github.actions.name"="Middleman Github Pages Action"
LABEL "com.github.actions.description"="Deploying your Middleman repo to the gh-pages branch of the same repository"
LABEL "com.github.actions.icon"="box"
LABEL "com.github.actions.color"="orange"

LABEL "repository"="http://github.com/yurikoval/middleman-gh-pages-action"

RUN apt-get update; \
apt-get install -y --no-install-recommends nodejs

ADD entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# A GitHub Action to Build and Deploy Middleman to Github Pages

A GitHub Action for building and deploying a Middleman repo to its `gh-pages` branch.

## Inputs

* `GITHUB_REPOSITORY`: Repo where built website will be published to
* `GITHUB_ACTOR`: Name of the deploy actor (defaults to `deploy`)
* `SITE_LOCATION`: Location of your Middleman project within the repo (defaults to project root)
* `REMOTE_BRANCH`: Name of the branch to push the project to (detaults to `gh-pages`)

## Example

Add this to `.github/workflows/gh-pages.yml` of your project.

```yaml
name: Middleman

on:
push:
branches: [master]

jobs:
build_and_deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build & Deploy to GitHub Pages
with:
GITHUB_REPOSITORY: me/my_repo
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: yurikoval/middleman-gh-pages-action@master
```
30 changes: 30 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

name: Middleman Github Pages Action
description: 'Deploying your Middleman repo to the gh-pages branch of the same repository'
author: "Yuri Koval'ov"
branding:
icon: 'box'
color: 'orange'
runs:
using: 'docker'
image: 'Dockerfile'
inputs:
GITHUB_REPOSITORY:
description: 'Github repository to push built site to'
required: true
GITHUB_ACTOR:
description: 'Name of the deploy actor'
required: false
default: 'deploy'
SITE_LOCATION:
description: 'Location of Middleman project within your repo'
required: false
default: '.'
BUILD_LOCATION:
description: 'Location where Middleman builds your website'
required: false
default: 'build'
REMOTE_BRANCH:
description: 'Branch name to push built sity to'
required: false
default: 'gh-pages'
27 changes: 27 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

echo 'Installing bundles...'
cd ${INPUT_SITE_LOCATION}
gem install bundler
bundle install
bundle list | grep "middleman ("

echo 'Building site...'
bundle exec middleman build

echo 'Publishing site...'
cd ${INPUT_BUILD_LOCATION}
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${INPUT_GITHUB_REPOSITORY}.git" && \
remote_branch=${INPUT_REMOTE_BRANCH} && \
git init && \
git config user.name "${INPUT_GITHUB_ACTOR}" && \
git config user.email "${INPUT_GITHUB_ACTOR}@users.noreply.github.com" && \
git add . && \
echo -n 'Files to Commit:' && ls -l | wc -l && \
git commit -m'Middleman build' > /dev/null 2>&1 && \
git push --force $remote_repo master:$remote_branch > /dev/null 2>&1 && \
rm -fr .git && \
cd ../
echo 'Done'

0 comments on commit 69b82c4

Please sign in to comment.