Skip to content

Commit

Permalink
Update worflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-vasilev committed May 1, 2024
1 parent a90e218 commit c4d9022
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 34 deletions.
52 changes: 46 additions & 6 deletions .github/actions/publish_pages/action.yml
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 }}
35 changes: 7 additions & 28 deletions .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,11 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
# Fetch all history for all branches and tags.
fetch-depth: 0
- name: Build DocC
shell: bash
run: |
mkdir ./docs;
swift build;
swift package \
--allow-writing-to-directory ./docs \
generate-documentation \
--target ${{ matrix.target }} \
--output-path ./docs/${{ matrix.base_path }} \
--transform-for-static-hosting \
--hosting-base-path flare/${{ matrix.base_path }};
- name: Commit and push generated documentation
run: |
git fetch
git worktree add --checkout gh-pages origin/gh-pages
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git switch gh-pages
rm -r ./${{ matrix.base_path }}
cp -r ./docs/${{ matrix.base_path }} ./${{ matrix.base_path }}
rm -r ./docs
git add ./${{ matrix.base_path }}
git commit -a -m "Generated ${{ matrix.target }} Swift DocC"
git push origin gh-pages
- name: Build and Push Generated Documentation
uses: space-code/oss-common-actions/.github/actions/publish_docc@main
with:
target: ${{ matrix.target }}
output_path: ${{ matrix.base_path }}
hosting_base_path: flare/${{ matrix.base_path }}

0 comments on commit c4d9022

Please sign in to comment.