Giter Club home page Giter Club logo

jekyll-deploy's Introduction

jekyll-deploy

Builds and deploys a jekyll page to GitHub pages.

Features:

  • build and test modes
  • record the site's source commit using a merge commit
  • build from any subdirectory in your repository
  • specify a target branch

Usage

To deploy every update to the main branch and regenerate the site once a day:

name: Jekyll Deploy

on:
  push:
    branches:
      # deploy on updates on main
      - main
  schedule:
    # redeploy every morning to update unpublished pages
    - cron: "0 2 * * *"

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache gems
        uses: actions/cache@v1
        with:
          path: vendor/gems
          key: ${{ runner.os }}-build-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-build-
            ${{ runner.os }}-

      - name: Build & Deploy to GitHub Pages
        uses: DavidS/jekyll-deploy@main
        env:
          JEKYLL_ENV: production
          GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}

To check PRs, set build-only: true:

name: Jekyll Test

on: [ pull_request ]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache gems
        uses: actions/cache@v1
        with:
          path: vendor/gems
          key: ${{ runner.os }}-build-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-build-
            ${{ runner.os }}-

      - name: Test
        uses: DavidS/jekyll-deploy@
        with:
          build-only: true
        env:
          JEKYLL_ENV: production
          GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}

The GH_PAGES_TOKEN needs the public_repo scope to be able to trigger deployments on a public repo or the full repo scope to deploy a private repository. Please note that this is circumventing GitHub's protection for infinitely recursive Actions invocations, so proceed with caution!

Specifying a source directory

If your site's source is not at the root of the repository, you can use the source-dir input to tell this action where the source can be found. For example, if your site is in a docs/jekyll subdirectory:

      - name: Build & Deploy to custom branch
        uses: DavidS/jekyll-deploy@
        with:
          source-dir: docs/jekyll
        env:
          JEKYLL_ENV: production
          GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}

Specifying a target branch

By default, this action deploys the compiled output to gh-pages, GitHub's default. If you want to use a different branch, you can use the target-branch input to do so. For example, to deploy to docs:

      - name: Build & Deploy to custom branch
        uses: DavidS/jekyll-deploy@main
        with:
          target-branch: docs
        env:
          JEKYLL_ENV: production
          GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}

jekyll-deploy's People

Contributors

davids avatar dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jekyll-deploy's Issues

fatal: Couldn't find remote ref gh-pages

My deployment workflow is failing with below error.

Initialized empty Git repository in /github/workspace/_site/.git/
fatal: Couldn't find remote ref gh-pages
/entrypoint.rb:7:in `exit': no implicit conversion from nil to integer (TypeError)
	from /entrypoint.rb:7:in `system_or_fail'
	from /entrypoint.rb:28:in `<main>'

I couldn't find the cause.

Deploy permissions need "repo" or "public_repo", not "repo_deployment".

The README says

The GH_PAGES_TOKEN needs the repo_deployment scope to be able to trigger deployments.

I just did some thorough tests and I found it's not repo_deployment; it's public_repo. A token with just public_repo can do Granting "repo" grants both.

Here's a token that just has X-OAuth-Scope: public_repo:

$ curl -X POST -v -H 'Authorization: token f19221032b2d42cb876161ec4545720229d8e3e3' -H 'Content-Type: application/json' https://api.github.com/repos/shimming-toolbox/shimming-toolbox.org/pages/builds                                         
*   Trying 140.82.112.6:443...
* TCP_NODELAY set
* Connected to api.github.com (140.82.112.6) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.github.com
*  start date: Jul  8 00:00:00 2019 GMT
*  expire date: Jul 16 12:00:00 2020 GMT
*  subjectAltName: host "api.github.com" matched cert's "*.github.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
*  SSL certificate verify ok.
> POST /repos/shimming-toolbox/shimming-toolbox.org/pages/builds HTTP/1.1
> Host: api.github.com
> User-Agent: curl/7.66.0
> Accept: */*
> Authorization: token f19221032b2d42cb876161ec4545720229d8e3e3
> Content-Type: application/json
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 Created
< Server: GitHub.com
< Date: Wed, 17 Jun 2020 01:10:55 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 103
< Status: 201 Created
< X-RateLimit-Limit: 5000
< X-RateLimit-Remaining: 4979
< X-RateLimit-Reset: 1592358878
< Cache-Control: private, max-age=60, s-maxage=60
< Vary: Accept, Authorization, Cookie, X-GitHub-OTP
< ETag: "181774e69295ed84245edd3ba1c451c7"
< X-OAuth-Scopes: public_repo
< X-Accepted-OAuth-Scopes: 
< Location: https://api.github.com/repositories/253874659/pages/builds/latest
< X-GitHub-Media-Type: github.v3; format=json
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Frame-Options: deny
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Content-Security-Policy: default-src 'none'
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-GitHub-Request-Id: 643D:2881:B45E5B:139041E:5EE96D9F
< 
{
  "status": "queued",
  "url": "https://api.github.com/repositories/253874659/pages/builds/latest"
}

And here's X-OAuth-Scopes: repo_deployment:

$ curl -X POST -v -H 'Authorization: token 4417a2f8e86b89cb8ede6cac7cba3ac982640ab7' -H 'Content-Type: application/json' https://api.github.com/repos/shimming-toolbox/shimming-toolbox.org/pages/builds                                         
*   Trying 140.82.112.6:443...
* TCP_NODELAY set
* Connected to api.github.com (140.82.112.6) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.github.com
*  start date: Jul  8 00:00:00 2019 GMT
*  expire date: Jul 16 12:00:00 2020 GMT
*  subjectAltName: host "api.github.com" matched cert's "*.github.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
*  SSL certificate verify ok.
> POST /repos/shimming-toolbox/shimming-toolbox.org/pages/builds HTTP/1.1
> Host: api.github.com
> User-Agent: curl/7.66.0
> Accept: */*
> Authorization: token 4417a2f8e86b89cb8ede6cac7cba3ac982640ab7
> Content-Type: application/json
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Server: GitHub.com
< Date: Wed, 17 Jun 2020 01:14:12 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 121
< Status: 404 Not Found
< X-RateLimit-Limit: 5000
< X-RateLimit-Remaining: 4978
< X-RateLimit-Reset: 1592358878
< X-OAuth-Scopes: repo_deployment
< X-Accepted-OAuth-Scopes: 
< X-GitHub-Media-Type: github.v3; format=json
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Frame-Options: deny
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Content-Security-Policy: default-src 'none'
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-GitHub-Request-Id: 53D9:0651:9E09AD:11C67EC:5EE96E64
< 
{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/repos/pages/#request-a-page-build"
}

(and don't worry both those tokens are revoked already)
Maybe the rule changed since you wrote the README?

CNAME file is deleted on deploy

Hey @DavidS ๐Ÿ‘‹

Thank you for this action!

I've noticed that CNAME file which is used to deploy jekyll site to custom domain is removed after commit to gh-pages branch (caused by git reset --soft origin/gh-pages). It would be nice to copy it from master branch on build.

I've fixed that by adding this line to entrypoint

FileUtils.cp('../CNAME', 'CNAME')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.