MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

Update UG GitHub Actions deployment sample workflow file #2555

Closed gerteck closed 3 months ago

gerteck commented 3 months ago

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

No response

Tell us about your environment

Windows 11

MarkBind version

5.5.2

Describe the bug and the steps to reproduce it

While exploring MarkBind as a User, I was following the UG to deploy via GitHub Actions to deploy my site on GitHub Pages for a newly set up repository. As the workflow permissions default to read-only (Settings>Actions>General), github-actions is not able to write to gh-pages.

Steps to reproduce

  1. Init new repo for new Markbind site
  2. Use template workflow file
  3. push to github for deployment

Bug/Nit description

Default GitHub Token Permissions:

GITHUB_TOKEN Permissions
  Contents: read
  Metadata: read
  Packages: read

Error 403 Forbidden:

info: Build success!
error: uncaughtException: remote: Permission to gerteck/repo-name/git denied to github-actions[bot].
fatal: unable to access 'https://github.com/user-name/repo-name.git/': The requested URL returned error: 403
ProcessError: remote: Permission to gerteck/mb-dev.git denied to github-actions[bot].

Proposed changes to UG:

name: Deploy MarkBind Site
on:
  push:
    branches: master

jobs:
  build:
    runs-on: ubuntu-latest
    name: test
+    permissions: 
+      contents: write
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '16'
      - run: npm i -g markbind-cli
      - run: markbind deploy --ci

Additionally, workflow reports success when the deployment can be considered to be erroneous, which has been raised in #1863.

While I don't think it is a big bug, perhaps a nit, but I think it would help to improve the onboarding process and make it easier for users to get started with MarkBind until they are more familiar configuring their own workflow.

Expected behavior

Deployment on github pages success:

info: Build success!
info: The website has been deployed at: https://user.github.io/repo-name

Anything else?

No response

gerteck commented 3 months ago

Additionally, perhaps changing the branch default master to the default main too could be a low hanging fruit.

Tim-Siu commented 3 months ago

It looks like I cannot deploy sites with CLI commands either. I will look into this as well.

Screenshot 2024-06-12 at 18 59 57
Tim-Siu commented 3 months ago

Hi @gerteck ,

Thank you for finding out this issue! Indeed they are some gaps in the documentation.

I tried your solution and it worked great! It should be able to help users onboard MarkBind smoother.

But I some how need to manually select deploy from branch to have the markbind site deployed. There was no error from the CI-run log. Maybe this is related to #2547 and gh-pages error?

Anyway, you can submit a Pull Request for your findings and earn credits. The change from master to main looks appropriate to me as well.

Thank you for your work!