Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images don't get published with the Action #8

Open
balint-bg opened this issue Mar 29, 2022 · 1 comment
Open

Images don't get published with the Action #8

balint-bg opened this issue Mar 29, 2022 · 1 comment

Comments

@balint-bg
Copy link

Hello,
I really like the idea of automatically converting my markdown to html and publishing them to GH pages via this action. Unfortunately I couldn't get images working.
I had a really basic setup, one of my markdown slides had images in it, using the normal syntax of:

Some text: ![](image_file_name.png)
Some other text: ![](some_other_image_file.png)

I've tried a number of iterations:

  • like above, having the image files in the same directory as the markdown file itself
  • putting the images in a <path_to_markdown_file>/docs/assets/images directory and using docs/assets/images/image_file_name.png inside the parens in my slides
  • putting the images in a <repo_root>/docs/assets/images directory
  • putting the images in a <repo_root>/img directory
    (the latter two make sense for not working I guess as my --input_dir doesn't contain the repo's root, see below)

None of which worked 😞

If i don't use this action, but commit my markdown slides to the gh-pages branch directly, the images do show up. But if I use the action, commit to devel and have the Action convert and publish then the images become broken links, with a 404 error.

I'm using the master version of your plugin. Here's my action config file:

# This is a basic workflow to help you get started with Actions

name: Publish Pages

# Controls when the action will run.
# Triggers the workflow on push events for the devel branch
on:
  workflow_dispatch:
  push:
    branches:
      - devel

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # TODO(balint) move to self hosted runners once the repo is allowed to use them
    # runs-on: [self-hosted]
    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - name: Build & Deploy to GitHub Pages
      env:
        MARP_ARGS: "--input-dir markdown_slides/ --output docs/"
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GITHUB_REPOSITORY: ${{ github.repository }}
        PUBLISH_TO_BRANCH: gh-pages

        # You'll want to set this to your domain
        BASE_URL: <my base URL is here>

      # consider using a tagged release here
      # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses
      uses: ralexander-phi/marp-action@master
@ralexander-phi
Copy link
Collaborator

Hey balint,

Try a relative path of ../markdown_slides/example.png.

The marp action should be committing the newly generated HTML files back to the repository on the specified PUBLISH_TO_BRANCH. In your case the markdown files like markdown_slides/example.md would be converted to docs/example.html. You should be able to access both the markdown and HTML files on GitHub pages at https://balint-bg.github.io/repo/markdown_slides/example.md and https://balint-bg.github.io/repo/docs/example.html. If the images for example.md are also in the markdown_slides/ folder then they'd be available as https://balint-bg.github.io/repo/markdown_slides/example.png.

Depending on how your GitHub pages site is deployed (I.E., github.io, dedicated custom domain, folder on custom domain) the exact path will vary. I suspect the examples above are creating paths like https://balint-bg.github.io/docs/assets/images/example.png. This is looking for a GitHub pages repository named docs and a folder assets/images/, which could explain the why the image does not load.

Let me know if that fixes the issue and thanks for trying out the action!

-Robert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants