helaili/jekyll-action

CNAME file should be copied to target branch by default

Closed this issue · 5 comments

It's very unexpected that the default process ignores CNAME file and so domain binding disappears.
As temporary fix for my case I create another step right after this one, but I pretty sure this must be in this script.

- name: Copy CNAME
        run: |
         git clone https://.:${{ secrets.GITHUB_TOKEN }}@github.com/msangel/msangel.github.io --depth 1 target
         git config --global user.email "h6.msangel+site-builder@gmail.com"
         git config --global user.name "Vasyl's script"
         cp target/CNAME CNAME
         cd target
         git fetch --depth 1 origin gh-pages:gh-pages
         git checkout gh-pages
         cp ./../CNAME CNAME
         git add CNAME
         git commit -m "restore CNAME"
         git push --set-upstream origin gh-pages
        shell: bash

+1 from me!

Optionally the contents for the CNAME file could be provided as an action input:

...
with: 
  cname: my.customdomain.com

If I understand correctly how GH actions work the implementation for this requirement would be something around:

action.yml:

inputs:
  cname:
    description: 'contents of the CNAME file'
    required: false

entrypoint.sh:

cd ${BUILD_DIR}

if [ -n "${INPUT_CNAME}" ]; then
  echo $INPUT_CNAME > CNAME
fi

I'd appreciate taking this suggestion into consideration 🙇

I had the same issue and found an easy way to solve it. Seems it's not a bug from jekyll-action. Just force the inclusion of CNAME.

Is this still an issue? I just used the latest version and saw the CNAME file in the gh-pages branch

Doesn't work for me when using a custom source dir. I tried forcing the inclusion, and it works great locally, but doesn't do anything when publishing.

Compare the source commit from which it should be built and deployed to the gh-pages branch:
https://github.com/lenkva/skolio.github.io/tree/4e6e3fbfb932cb4186ff7244b026206f31a70dcb

Deployed by the action:
https://github.com/lenkva/skolio.github.io/actions/runs/2723429576

And the built / deployed output:
https://github.com/lenkva/skolio.github.io/tree/7989434e1caf2385b25c9b1105b1bed0033434c6

I moved the CNAME to the root in
https://github.com/lenkva/skolio.github.io/tree/0860b0df613f1690a6690222bbd1685e4308bde7
With the exact same result:
https://github.com/lenkva/skolio.github.io/tree/ae0c0e062a0e42f46fadc389bfe17711ddf6a815

Update: It seems that it's a problem with the source setting in the jekyll config. I'm going to open a separate issue for that.