Skip to content

Commit

Permalink
v1: Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed Apr 24, 2020
1 parent accd1e2 commit 1ee6849
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FROM python:3.8

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Nikola, a static site generator
Copyright (c) 2020 Chris Warrick and Roberto Alsina

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
# nikola-action
Github Action for building a Nikola site and deploying to GH Pages
# getnikola/nikola-action: a GitHub Action for building a Nikola site and deploying it to GitHub Pages.

This GitHub Action can build and deploy a Nikola website.

# Usage

1. Create a repository with a Nikola site.
2. Configure [nikola github_deploy](https://getnikola.com/handbook.html#deploying-to-github). It’s best to do your first deployment from your local machine.
3. Ensure the correct branch for deployment is set on GitHub. Refer to [this guide](https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-first-deployment-with-github_token).
4. Create a `.github/workflows/main.yml` file with the Sample Workflow.

## Sample Workflow

```yml
on: [push]

jobs:
nikola_build:
runs-on: ubuntu-latest
name: 'Deploy Nikola to GitHub Pages'
steps:
- name: Check out
uses: actions/checkout@v2
- name: Build and Deploy Nikola
uses: getnikola/nikola-action@v1
```
## Extras
By default, the action will install the latest stable release of `Nikola[extras]`. If you want to use the bleeding-edge version from `master`, or want to install some extra dependencies, you can provide a `requirements.txt` file in the repository.
8 changes: 5 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# action.yml
name: 'Deploy to GH Pages'
description: 'Build the site using Nikola and deploy to GH Pages'
name: 'Deploy Nikola to GitHub Pages'
description: 'Build the site using Nikola and deploy to GitHub Pages'
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'zap'
color: 'orange'
29 changes: 24 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@ set -e
echo "REPO: $GITHUB_REPOSITORY"
echo "ACTOR: $GITHUB_ACTOR"

echo '# Install Requirements'
pip install -r requirements.txt
echo '# Build site'
echo "==> Preparing..."
src_branch="$(python -c 'import conf; print(conf.GITHUB_SOURCE_BRANCH)')"
dest_branch="$(python -c 'import conf; print(conf.GITHUB_DEPLOY_BRANCH)')"

git remote add ghpages "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git fetch ghpages $dest_branch
git checkout -b $dest_branch --track ghpages/$dest_branch || true
git pull ghpages $dest_branch || true
git checkout $src_branch

# Override config so that ghp-import does the right thing.
printf '\n\nGITHUB_REMOTE_NAME = "ghpages"\nGITHUB_COMMIT_SOURCE = False\n' >> conf.py

echo "==> Installing requirements..."
if [[ -f "requirements.txt" ]]; then
# Since people might type just 'nikola', we force ghp-import2 to be installed.
pip install -r requirements.txt ghp-import2
else
pip install "Nikola[extras]"
fi

echo "==> Building site..."
nikola build
echo '# Publish to GitHub Pages'
echo "==> Publishing..."
nikola github_deploy
echo '# Done'
echo "==> Done!"

0 comments on commit 1ee6849

Please sign in to comment.