-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a90e218
commit 4df1ffc
Showing
2 changed files
with
53 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,66 @@ | ||
name: Publish Page Action | ||
name: Build and Publish Documentation | ||
|
||
inputs: | ||
target: | ||
required: true | ||
type: string | ||
base_path: | ||
output_path: | ||
required: true | ||
type: string | ||
hosting_base_path: | ||
required: true | ||
type: string | ||
branch_name: | ||
required: true | ||
type: string | ||
default: gh-pages | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Create a directory for documentation | ||
shell: bash | ||
run: mkdir ./docs; | ||
|
||
- name: Build the package | ||
shell: bash | ||
run: swift build; | ||
|
||
- name: Build DocC | ||
shell: bash | ||
run: | | ||
mkdir ./docs; | ||
swift build; | ||
swift package \ | ||
--allow-writing-to-directory ./docs \ | ||
generate-documentation \ | ||
--target ${{ inputs.target }} \ | ||
--output-path ./docs/${{ inputs.base_path }} \ | ||
--output-path ./docs/${{ inputs.output_path }} \ | ||
--transform-for-static-hosting \ | ||
--hosting-base-path flare/${{ inputs.base_path }}; | ||
--hosting-base-path ${{ inputs.hosting_base_path }}; | ||
- name: Commit and push generated documentation | ||
shell: bash | ||
run: | | ||
git fetch | ||
git worktree add --checkout ${{ inputs.branch_name }} origin/${{ inputs.branch_name }} | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git switch ${{ inputs.branch_name }} | ||
rm -r ./${{ inputs.output_path }} | ||
cp -r ./docs/${{ inputs.output_path }} ./${{ inputs.output_path }} | ||
rm -r ./docs | ||
git add ./${{ inputs.output_path }} | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "Documentation changes found. Commiting the changes to the '${{ inputs.branch_name }}' branch and pushing to origin." | ||
git commit -a -m "Generated ${{ inputs.target }} Swift DocC" | ||
git push origin ${{ inputs.branch_name }} | ||
else | ||
# No changes found, nothing to commit. | ||
echo "No documentation changes found." | ||
fi | ||
git worktree remove ${{ inputs.branch_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters