Changed wiki deploy script to include subdirectories (#87)
Co-authored-by: Henry Pauli <henry@mixict.nl>
This commit is contained in:
		
							
								
								
									
										76
									
								
								.github/deploy_wiki.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										76
									
								
								.github/deploy_wiki.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
function debug() {
 | 
			
		||||
    echo "::debug file=${BASH_SOURCE[0]},line=${BASH_LINENO[0]}::$1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function warning() {
 | 
			
		||||
    echo "::warning file=${BASH_SOURCE[0]},line=${BASH_LINENO[0]}::$1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function error() {
 | 
			
		||||
    echo "::error file=${BASH_SOURCE[0]},line=${BASH_LINENO[0]}::$1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function add_mask() {
 | 
			
		||||
    echo "::add-mask::$1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [ -z "$GITHUB_ACTOR" ]; then
 | 
			
		||||
    error "GITHUB_ACTOR environment variable is not set"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$GITHUB_REPOSITORY" ]; then
 | 
			
		||||
    error "GITHUB_REPOSITORY environment variable is not set"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$GH_PERSONAL_ACCESS_TOKEN" ]; then
 | 
			
		||||
    error "GH_PERSONAL_ACCESS_TOKEN environment variable is not set"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$WIKI_PATH" ]; then
 | 
			
		||||
    echo "WIKI_PATH environment variable is not set"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
add_mask "${GH_PERSONAL_ACCESS_TOKEN}"
 | 
			
		||||
 | 
			
		||||
if [ -z "${WIKI_COMMIT_MESSAGE:-}" ]; then
 | 
			
		||||
    debug "WIKI_COMMIT_MESSAGE not set, using default"
 | 
			
		||||
    WIKI_COMMIT_MESSAGE='Automatically publish wiki'
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
GIT_REPOSITORY_URL="https://${GH_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git"
 | 
			
		||||
 | 
			
		||||
debug "Checking out wiki repository"
 | 
			
		||||
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
 | 
			
		||||
(
 | 
			
		||||
    cd "$tmp_dir" || exit 1
 | 
			
		||||
    git init
 | 
			
		||||
    git config user.name "$GITHUB_ACTOR"
 | 
			
		||||
    git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
 | 
			
		||||
    git pull "$GIT_REPOSITORY_URL"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
debug "Rsync contents of $WIKI_PATH"
 | 
			
		||||
rsync -q -a --delete "$GITHUB_WORKSPACE/$WIKI_PATH/" "$tmp_dir"
 | 
			
		||||
 | 
			
		||||
if [ ! -r "$tmp_dir/Home.md" ]; then
 | 
			
		||||
    debug "Copy README.md to wiki/Home.md"
 | 
			
		||||
    rsync -q -a "$GITHUB_WORKSPACE/README.md" "$tmp_dir/Home.md"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
debug "Committing and pushing changes"
 | 
			
		||||
(
 | 
			
		||||
    cd "$tmp_dir" || exit 1
 | 
			
		||||
    git add .
 | 
			
		||||
    git commit -m "$WIKI_COMMIT_MESSAGE"
 | 
			
		||||
    git push --set-upstream "$GIT_REPOSITORY_URL" master
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
rm -rf "$tmp_dir"
 | 
			
		||||
exit 0
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								.github/workflows/publish_wiki.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/workflows/publish_wiki.yml
									
									
									
									
										vendored
									
									
								
							@@ -13,12 +13,9 @@ jobs:
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout branch
 | 
			
		||||
        uses: actions/checkout@v1
 | 
			
		||||
      - name: Copy README.md to wiki/Home.md
 | 
			
		||||
        run: cp -f README.md wiki/Home.md
 | 
			
		||||
      - name: Upload to Wiki
 | 
			
		||||
        uses: SwiftDocOrg/github-wiki-publish-action@v1
 | 
			
		||||
        with:
 | 
			
		||||
          path: "wiki"
 | 
			
		||||
      - name: Upload Documentation to Wiki
 | 
			
		||||
        run: bash ./.github/deploy_wiki.sh
 | 
			
		||||
        env:
 | 
			
		||||
          GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
 | 
			
		||||
          WIKI_PATH: "wiki"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user