Skip to content

Commit

Permalink
V2 (#5)
Browse files Browse the repository at this point in the history
* Create action.yml
* Update Dockerfile
* Update README.md
* Update entrypoint.sh
* Update GitHub-Pages-deploy.gif
  • Loading branch information
ArnaudLigny authored Nov 17, 2019
1 parent f6dc646 commit cd4e82a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
10 changes: 1 addition & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
FROM alpine/git:latest

LABEL "com.github.actions.name"="GH Pages deploy"
LABEL "com.github.actions.description"="A GitHub Action to deploy a static site on GitHub Pages."
LABEL "com.github.actions.icon"="upload-cloud"
LABEL "com.github.actions.color"="black"

LABEL "repository"="https://github.com/Cecilapp/GitHub-Pages-deploy"
LABEL "homepage"="https://github.com/Cecilapp/GitHub-Pages-deploy"
LABEL "maintainer"="Arnaud Ligny <[email protected]>"

ADD entrypoint.sh /
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
Binary file modified GitHub-Pages-deploy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
- name: Deploy to GitHub Pages
uses: Cecilapp/GitHub-Pages-deploy@master
env:
BUILD_DIR: _site/ # "_site/" by default
CNAME: narno.com # in case of custom domain
EMAIL: [email protected] # must be a verified email
JEKYLL_SITE: "YES" # only in case of a Jekyll site
EMAIL: [email protected] # must be a verified email
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} # https://github.com/settings/tokens
BUILD_DIR: _site/ # "_site/" by default
CNAME: narno.com # in case of custom domain
JEKYLL_SITE: "YES" # only in case of a Jekyll site
```
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'GH Pages deploy'
description: 'A GitHub Action to deploy a static site on GitHub Pages.'
author: 'Arnaud Ligny'
branding:
icon: 'upload-cloud'
color: 'black'

runs:
using: 'docker'
image: 'Dockerfile'
34 changes: 21 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
set -e

# commiter email
if [ -z "$EMAIL" ]
then
if [ -z "$EMAIL" ]; then
echo "A verified email is required"
exit 1
fi
Expand All @@ -17,8 +16,7 @@ else
TARGET_BRANCH="gh-pages"
fi
# build dir
if [ -z "$BUILD_DIR" ]
then
if [ -z "$BUILD_DIR" ]; then
BUILD_DIR="_site"
fi

Expand All @@ -28,21 +26,31 @@ cp -R $BUILD_DIR $HOME/$BUILD_DIR
cd $HOME
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$EMAIL"
git clone --quiet --branch=$TARGET_BRANCH https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git $TARGET_BRANCH > /dev/null
cp -R gh-pages/.git $HOME/.git
rm -rf gh-pages/*
cp -R $HOME/.git gh-pages/.git
cd gh-pages
if [ -z "$(git ls-remote --heads https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git ${TARGET_BRANCH})" ]; then
git clone --quiet https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git $TARGET_BRANCH > /dev/null
cd $TARGET_BRANCH
git checkout --orphan $TARGET_BRANCH
git rm -rf .
echo "$REPONAME" > README.md
git add README.md
git commit -a -m "Create $TARGET_BRANCH branch"
git push origin $TARGET_BRANCH
cd ..
else
git clone --quiet --branch=$TARGET_BRANCH https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git $TARGET_BRANCH > /dev/null
fi
cp -R $TARGET_BRANCH/.git $HOME/.git
rm -rf $TARGET_BRANCH/*
cp -R $HOME/.git $TARGET_BRANCH/.git
cd $TARGET_BRANCH
cp -Rf $HOME/${BUILD_DIR}/* .
# custom domain?
if [ ! -z "$CNAME" ]
then
if [ ! -z "$CNAME" ]; then
echo "Add custom domain file"
echo "$CNAME" > CNAME
fi
# .nojekyll
if [ "$JEKYLL_SITE" != "YES" ]
then
if [ "$JEKYLL_SITE" != "YES" ]; then
echo "Disable Jekyll"
touch .nojekyll
fi
Expand Down

0 comments on commit cd4e82a

Please sign in to comment.