Decathlon / wiki-page-creator-action

Create a GitHub wiki page based on the provided markdown file
Apache License 2.0
94 stars 20 forks source link

MD_FOLDER can't access outside of docker container #19

Closed theofficialgman closed 3 years ago

theofficialgman commented 3 years ago

I have a usecase where the github actions itself generates the markdown files (through bash that runs prior) and the files are not in the github repo.

How can I mount the files from outside the docker container so that they can be accessed within the docker?

mmornati commented 3 years ago

Good point. Actually it is working as a "standard" GitHub Action: we mount inside the docker the whole repository file system. So it should work even for your case. The whole example on the readme is doing something like you would like to do I guess:

elease-notes:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Create Release Notes
      uses: docker://decathlon/release-notes-generator-action:2.0.0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        OUTPUT_FOLDER: temp_release_notes
        USE_MILESTONE_TITLE: "true"
    - name: Upload Release Notes to Wiki
      uses: docker://decathlon/wiki-page-creator-action:latest
      env:
        ACTION_MAIL: myuser@users.noreply.github.com
        ACTION_NAME: myPushingUser
        GH_PAT: ${{ secrets.GH_PAT }}
        MD_FOLDER: temp_release_notes
        OWNER: yourGitHubOrganisation
        REPO_NAME: yourGitHubRepository
        SKIP_MD: README.md

There is a different between the github repo files and the github action's file system. All the repo file are available after a first clone, and everything happening on this file system then is shared between action (log files, working files, ...).

theofficialgman commented 3 years ago

I appreciate the response! I actually realized that was the case by looking at the log (how the repo folder gets mounted to the docker) I just moved the files to inside the repo earlier in the github actions to accomplish what I was trying to do.

The only thing I would like to know would be if I could relatively easily pass a -v (volume mount) command to your docker container or not?

anyway, the reason I asked in the first place is my github action pulls a file and a script from the github repo, the script is run on that file (generating the .md page) and then your docker container uploads that generated .md to the wiki.

I was using another github action similar to this one that would clean the github repo on launch and didn't realize till after I posted this that yours doesn't do that (which is good because that means I can just move the files inside the repo directory)

theofficialgman commented 3 years ago

just to show, this is the github actions that I do that works nicely


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

name: Update_Wiki_Scripts

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
#   push:
#     branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# 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"
  update-wiki:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          chmod +x $GITHUB_WORKSPACE/assets/conversion_wiki.sh
          cd $GITHUB_WORKSPACE
          mkdir wikioutput
          cd wikioutput
          $GITHUB_WORKSPACE/assets/conversion_wiki.sh
          cat Home.md

      - name: "Set environmental variables"
        run: |
          echo "ACTION_MAIL=$GITHUB_ACTOR@users.noreply.github.com" >> $GITHUB_ENV
          echo "ACTION_NAME=$GITHUB_ACTOR" >> $GITHUB_ENV
          echo "OWNER=$GITHUB_ACTOR" >> $GITHUB_ENV
          echo "REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

      - name: Upload scripts page to wiki
        uses: docker://decathlon/wiki-page-creator-action:latest
        env:
          GH_PAT: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          MD_FOLDER: "/github/workspace/wikioutput"     
mmornati commented 3 years ago

For MD_FOLDER on my tests, I never put the whole path but the relative. For what you are showing I guess on your side should be

 MD_FOLDER: "wikioutput" 

But then as you are moving around with all of these:

cd $GITHUB_WORKSPACE 
mkdir wikioutput
cd wikioutput

You can maybe try to add another Action step to list the folder content and be sure exactly where your folder is?

- name: Run a multi-line script
        run: |
          ls -l
          ls -l wikioutput

Anyway as I said, the file is created in the Action context which is automatically mounted in all the Workflow's actions.

mmornati commented 3 years ago

I appreciate the response! I actually realized that was the case by looking at the log (how the repo folder gets mounted to the docker) I just moved the files to inside the repo earlier in the github actions to accomplish what I was trying to do.

The only thing I would like to know would be if I could relatively easily pass a -v (volume mount) command to your docker container or not?

anyway, the reason I asked in the first place is my github action pulls a file and a script from the github repo, the script is run on that file (generating the .md page) and then your docker container uploads that generated .md to the wiki.

I was using another github action similar to this one that would clean the github repo on launch and didn't realize till after I posted this that yours doesn't do that (which is good because that means I can just move the files inside the repo directory)

I didn't test adding a new volume (and I don't know if the GitHub actions allow this... it is a Docker but the startup is managed by the GitHub Action Runners). But as everything is automatically mounted, I'm not sure it is really interesting to have a differrent mount point but just browse to the correct folder.

mmornati commented 3 years ago

For MD_FOLDER on my tests, I never put the whole path but the relative. For what you are showing I guess on your side should be

 MD_FOLDER: "wikioutput" 

But then as you are moving around with all of these:

cd $GITHUB_WORKSPACE 
mkdir wikioutput
cd wikioutput

You can maybe try to add another Action step to list the folder content and be sure exactly where your folder is?

- name: Run a multi-line script
        run: |
          ls -l
          ls -l wikioutput

Anyway as I said, the file is created in the Action context which is automatically mounted in all the Workflow's actions.

In the end I noticed after you fixed your problem... that's great. If I can help for any other thing, I'm available (working time allowing 😂)

theofficialgman commented 3 years ago

oh yeah thanks for the help. i was able to solve it. I'll close this issue