Giter VIP home page Giter VIP logo

wiki-sync-action's Introduction

Community Project header

Bi-directional Wiki Sync Action

GitHub Marketplace version

A GitHub Action that synchronizes the contents of a directory to the repository's Wiki.

This project is a fork of SwiftDocOrg/github-wiki-publish-action and attribution is noted in the THIRD_PARTY_NOTICES.md. The basic enhancement is this adds syncronization so edits made directly to the Wiki can flow back to the repo directory.

Note: This "sync" only works for create/update of a file in the wiki. Deletes will not propogate back due to limitations of the GitHub API gollum event. For deletes, remove the file from the directory and the directory -> wiki sync will remove the file.

Inputs

Key Required Default Description
source yes - Source directory/location of file sync (ex: docs).
destination yes - Destination directory/location for file sync (ex: wiki).
token yes - Github personal access token with at least 'repo' authorization.
gitAuthorName no github.actor Author name to use for committing to repository.
gitAuthorEmail no [email protected] Author name to use for committing to repository.
branch no master Default branch to commit to. Only needed when syncing wiki to a directory.
commitMessage no chore(docs): Sync $SOURCE to $DESTINATION [skip-cd] Message for committing files to repository.

Example Usage

This Action is utilized by opensource.newrelic.com to keep our docs and Wiki in sync. To see the implementation, visit newrelic/opensource-website.

Wiki: opensource-website wiki

Workflows: workflow runs

Bi-directional Sync Workflow

The following example shows how to use the wiki-sync-action in conjunction with the gollum event.

NOTE: Either source or destination must be set to wiki. The action will error out if an attempt is made to not sync a directory with the wiki.

name: Documentation

on:
  push:
    branches:
      - develop
    paths:
      - "docs/**"
  repository_dispatch:
    types: [docs]
  gollum:

env:
  GIT_AUTHOR_NAME: Actionbot
  GIT_AUTHOR_EMAIL: [email protected]

jobs:
  job-sync-docs-to-wiki:
    runs-on: ubuntu-latest
    if: github.event_name != 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Sync docs to wiki
        uses: newrelic/wiki-sync-action@main
        with:
          source: docs
          destination: wiki
          token: ${{ secrets.NEWRELIC_BOT_TOKEN }}
          gitAuthorName: ${{ env.GIT_AUTHOR_NAME }}
          gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }}
  
  job-sync-wiki-to-docs:
    runs-on: ubuntu-latest
    if: github.event_name == 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.NEWRELIC_BOT_TOKEN }} # allows us to push back to repo
          ref: develop
      - name: Sync Wiki to Docs
        uses: newrelic/wiki-sync-action@main
        with:
          source: wiki
          destination: docs
          token: ${{ secrets.NEWRELIC_BOT_TOKEN }}
          gitAuthorName: ${{ env.GIT_AUTHOR_NAME }}
          gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }}
          branch: develop # since default branch is develop in this example

Support

New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:

https://discuss.newrelic.com/t/open-source-maintainers-keep-repo-documentation-in-sync-with-the-bi-directional-wiki-sync-github-action/105611

Contributing

Contributions are encouraged! If you submit an enhancement request, we'll invite you to contribute the change yourself. Please review our Contributors Guide.

Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at [email protected].

License

Wiki Sync Action is licensed under the Apache 2.0 License.

The wiki-sync-action also uses source code from third party libraries. Full details on which libraries are used and the terms under which they are licensed can be found in the third party notices document.

wiki-sync-action's People

Contributors

islerfab avatar jbeveland27 avatar nr-opensource-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wiki-sync-action's Issues

Bug: src refspec docs/update-from-wiki does not match any

Description

Heya guys, Encountering an issue when changing a markdown file in the repo.wiki.git through the online editor. Not entirely sure what the error is due to the lack of console output information, but here is everything you should need.

name: Documentation

on:
  push:
    paths:
      - "docs/**"
  repository_dispatch:
    types: [docs]
  gollum:

jobs:
  # syncs from the github inbuilt wiki
  job-sync-wiki-to-docs:
    name: Sync from wiki
    runs-on: ubuntu-latest
    if: github.event_name == 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          ref: master
      - name: Sync Wiki to Docs
        uses: newrelic/wiki-sync-action@master
        with:
          source: wiki
          destination: docs
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: 'docs/update-from-wiki'
      - name: pull-request
        uses: repo-sync/pull-request@v2
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          source_branch: 'master'
          destination_branch: 'docs/update-from-wiki'
          pr_title: "docs: updating docs from wiki"
          pr_body: ":crown: *An automated PR*"
          pr_label: "skip-changelog"

Expected Behaviour

Expected to checkout repo.wiki.git, and sync them with master document (docs) folder. Then push to branch docs/update-from-wiki

Relevant Logs / Console output

[master 1dcc623] chore(docs): Sync wiki to docs [skip-cd]
 3 files changed, 87 insertions(+)
 create mode 100644 docs/Home.md
 create mode 100644 docs/_Footer.md
error: src refspec docs/update-from-wiki does not match any
 create mode 100644 docs/_Sidebar.md
error: failed to push some refs to 'https://github.com/Videndum/Smartcloud'

fatal: could not read Password for 'https://***@github.com'

When I try to sync my documentation to the wiki I get the following exception:

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

Description

When I try to sync the documentation to the wiki for project https://github.com/UniKnow/jsoar I get the above exception. The default branch for the project is maven and wiki is enabled.

Relevant Logs / Console output

See this build: https://github.com/UniKnow/jsoar/actions/runs/927556596

Bug: access denied or repository not exported error stops action from working

Description

  • When running either the docs-to-wiki or wiki-to-sync job, there is an error printed to the action logs stating fatal: remote error: access denied or repository not exported: [Stuff that looks like /a/b/cc/dd/ee/8359252938].wiki.git

Steps to Reproduce

Used the following actions config file:

name: Docs/Wiki Sync

on:
  push:
    branches:
      - main
    paths:
      - "docs/**"
  repository_dispatch:
    types: [docs]
  gollum:

env:
  GIT_AUTHOR_EMAIL: [email protected]
  GIT_AUTHOR_NAME: nr-opensource-bot

jobs:
  job-sync-docs-to-wiki:
    runs-on: ubuntu-latest
    if: github.event_name != 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Sync docs to wiki
        uses: newrelic/wiki-sync-action@master
        with:
          source: docs
          destination: wiki
          token: ${{ secrets.WIKI_SYNC_TOKEN }}
          gitAuthorName: ${{ env.GIT_AUTHOR_NAME }}
          gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }}

  job-sync-wiki-to-docs:
    runs-on: ubuntu-latest
    if: github.event_name == 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.WIKI_SYNC_TOKEN }} # allows us to push back to repo
          ref: main
      - name: Sync Wiki to Docs
        uses: newrelic/wiki-sync-action@master
        with:
          source: wiki
          destination: docs
          token: ${{ secrets.WIKI_SYNC_TOKEN }}
          gitAuthorName: ${{ env.GIT_AUTHOR_NAME }}
          gitAuthorEmail: ${{ env.GIT_AUTHOR_EMAIL }}
          branch: main

I also tried with the GITHUB_TOKEN passed through actions instead of making a secret in the repository

I also tried making the repository public to see if that helped

I then edited a document in the docs folder and observed the action being run

Expected Behaviour

The action should have synced the docs to the wiki

Relevant Logs / Console output

fatal: remote error: access denied or repository not exported: /*/**/**/**/**/*********/*********.wiki.git
sending incremental file list
./
**.md
**.md
**.md

sent 402 bytes  received 76 bytes  956.00 bytes/sec
total size is 142  speedup is 0.30
[master (root-commit) 9e652e3] chore(docs): Sync docs to wiki [skip-cd]
 3 files changed, 21 insertions(+)
 create mode 100644 **.md
 create mode 100644 **.md
 create mode 100644 **.md
fatal: could not read Password for 'https://***@github.com': No such device or address

Your Environment

As per the action

Additional context

Workflow succeeds on fatal git error caused by an empty gitAuthorEmail.

Description

I have a workflow setup where I tried to use gitAuthorEmail: ${{ github.event.sender.email }} for wiki -> docs sync. That value is apparently blank and git had a fatal error (fatal: empty ident name (for <@users.noreply.github.com>) not allowed) but the workflow was regarded as successful in github.

Steps to Reproduce

Working workflow.yml with comment about where the error occurs (near the end)
name: Wiki Sync

on:
  push:
    branches:
      - master
    paths:
      - "doc/wiki/**"
  # Wiki events generated by github.
  # Only created and updated are sent, if a page is deleted from the wiki's web UI,
  # it will not be synced. Deletes should happen on the local file for it to be
  # synced to the wiki repo.
  gollum:

permissions: write-all

jobs:
  job-sync-docs-to-wiki:
    runs-on: ubuntu-latest
    if: github.event_name != 'gollum' && github.event.commits[0].author.email != '[email protected]'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Sync docs to wiki
        uses: newrelic/wiki-sync-action@8fb7a9efe4e975bdb2977107fbed96fa0433db52
        with:
          source: doc/wiki
          destination: wiki
          token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          gitAuthorName: ${{ github.event.pusher.name }}
          gitAuthorEmail: ${{ github.event.pusher.email }}
          commitMessage: ${{ github.event.head_commit.message }}


  job-sync-wiki-to-docs:
    runs-on: ubuntu-latest
    if: github.event_name == 'gollum'
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          ref: master
      - name: Sync Wiki to Docs
        uses: newrelic/wiki-sync-action@8fb7a9efe4e975bdb2977107fbed96fa0433db52
        with:
          source: wiki
          destination: doc/wiki
          token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          gitAuthorName: WikiSyncBot
          # 
          # 
          #  Fails when using the EMPTY value:
          #  github.event.sender.email
          #          
          gitAuthorEmail: [email protected]
          commitMessage: |
            Wiki-sync: ${{ join(github.event.pages.*.page_name) }}

            ${{ toJson(github.event.pages) }}
          branch: master

Expected Behaviour

If git fails to commit, the sync has failed and therefore the workflow should fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.