How to updade repo wiki from Github Actions

Is there an easy way to update repo wiki from Github Actions?

I’ve tried cloning it but it does not work:

        export URL=ssh://${{ github.token }}@github.com/${{ github.repository }}.wiki
        git clone $URL ${BUILD_DIR}/markdown

I am getting

Warning: Permanently added the RSA host key for IP address ‘140.82.114.4’ to the list of known hosts.

***@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

with https I am getting
Cloning into ‘/home/runner/work/_temp/build/markdown’…

fatal: could not read Password for ‘https://***@github.com’: No such device or address

Is there an easy way to get wiki related to the repo ?

E.g. when one checks out repo, could there be an option to checkout wiki too ?

Hi @JacekPliszka,

Glad to see you in Github Community Forum!

Github repo wiki is actually a repo with named reponame.wiki, hence you can specify the wiki repo name to actions/checkout to checkout it. Code sample as below:

      - uses: actions/checkout@v2
        with:
          repository: ${{github.repository}}.wiki    # specify the wiki repo name here.
        
      - name: check wiki repo content
        run: |
          ls -al
      - name: edit wiki
        run: |
          echo test >> test.md
      - name: Commit files
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add .
          git commit -m "Add changes"
      - name: Push changes to wiki repo
        uses: ad-m/github-push-action@master
        with:
          repository: ${{github.repository}}.wiki    # specify the wiki repo and push the update.
          github_token: ${{ secrets.GITHUB_TOKEN }}

Please refer to my workflow for more details.

BTW, you can also search existing actions in markeplace here, for example, use action ‘SwiftDocOrg/github-wiki-publish-action@v1’ to publish content to wiki.

Hope it clear and helpful!

Thank you, I should’ve specified a bit more what I needed but with your suggestion it worked great.

What I needed is to have both base repo and wiki at the same time. But in addition to repository parameter there is path parameter so everything works great now.

Hi @JacekPliszka,

Thanks for your reply! Yes, you can use path parameter of actions/checkout to store base repo and wiki repo seperately. Glad to know it works for you and issue is gone.

Happy coding!

If I now understand this right, should the GITHUB_TOKEN have write access to the wiki, so that I could f.e. define it as the GH_PAT enviroment for the Decathlon/wiki-page-creator-action?

I did not have to do anything - all I did was

    - name: Checkout base code
      uses: actions/checkout@v2
      with:
        path: base-code
    - name: Checkout wiki code
      uses: actions/checkout@v2
      with:
        repository: ${{github.repository}}.wiki
        path: markdown
    - name: Push to wiki
      run: |
        cd markdown
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git add .
        git diff-index --quiet HEAD || git commit -m "Add changes" && git push

Hi @andre601,

Yes, GITHUB_TOKEN has write access to the wiki. Decathlon/wiki-page-creator-action is a third-party action, you can use it with token to publish wikipages to the repository.

Hi @JacekPliszka,

Since the issue is resloved, could you please help to mark the answer? It could be helpful to other who has same queries. Let me know if you have any questions.

Thanks.

good to know,

However do I face the issue, that the action I use doesn’t work with the GITHUB_TOKEN secret, either because of how the action handles git actions or because of the repo being part of an organisation.
Do orgs have a different behaviour for wikis or should the same action work?

Hi @andre601,

The action Decathlon/wiki-page-creator-action seems to handle the access as a remote repository which ‘GITHUB_TOKEN’ doesn’t work, have to use PAT secrets.

Actually in my example, you can find GITHUB_TOKEN can push update to wiki repo. You can follow it, submit your changes to wiki.

Thanks.