helaili / jekyll-action

A GitHub Action to publish Jekyll based content as a GitHub Pages site
MIT License
250 stars 120 forks source link

Building in a with path directory #42

Closed ghost closed 4 years ago

ghost commented 4 years ago

I'm working with the COSMOS project and I have a workflow yml as follows in my 'website' branch:

name: Build and deploy Jekyll site to GitHub Pages

on:
  push:
    branches:
      - website

jobs:
  github-pages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/checkout@v2
        with:
          ref: master
          path: COSMOS

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

      - uses: helaili/jekyll-action@2.0.3
        env:
          JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}

While this works it ends up pushing our entire repo into the gh-pages branch since the COSMOS checkout is a nested directory. I tried the following to checkout both the website and COSMOS to different directories:

name: Build and deploy Jekyll site to GitHub Pages

on:
  push:
    branches:
      - website

jobs:
  github-pages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          path: jekyll_site

      - uses: actions/checkout@v2
        with:
          ref: master
          path: COSMOS

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

      - uses: helaili/jekyll-action@2.0.3
        env:
          JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}
        with:
          jekyll_src: jekyll_site

However this failed with "Could not locate Gemfile":

Run helaili/jekyll-action@2.0.3
  with:
    jekyll_src: jekyll_site
  env:
    JEKYLL_PAT: ***
/usr/bin/docker run --name d388ca49cccb514e9f926c4f7df2b8c43b_2a329a --label 3888d3 --workdir /github/workspace --rm -e JEKYLL_PAT -e INPUT_JEKYLL_SRC -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/COSMOS/COSMOS":"/github/workspace" 3888d3:88ca49cccb514e9f926c4f7df2b8c43b  "jekyll_site"
Starting the Jekyll Action
Could not locate Gemfile
helaili commented 4 years ago

Can you try this:

name: Build and deploy Jekyll site to GitHub Pages

on:
  push:
    branches:
      - website

jobs:
  github-pages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v1
         with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - uses: helaili/jekyll-action@2.0.3
         env:
          JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}
ghost commented 4 years ago

That would work if I didn't also have to check out the master branch. One of my jekyll jobs is to run against the master branch (expected to be checked out to ../COSMOS) to collect information for our documentation. We may be structuring things a little differently than normal. We have our code in the master branch, a dedicated 'website' branch for the site source, and of course the 'gh-pages' branch for the deployed site.

helaili commented 4 years ago

🤔 both master and website have a Gemfile so it means you're (maybe) overwriting one with the other. This seems a bit complicated.

What about turning the website branch into a directory within master? Then, once we merge #35 🔜 you'll be able to specify which Gemfile to use and will end up with a simpler workflow.

ghost commented 4 years ago

@helaili thanks I will look into that