-
Notifications
You must be signed in to change notification settings - Fork 0
Reusable Documentation Workflows #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beauremus
wants to merge
13
commits into
main
Choose a base branch
from
documentation-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2fc9a5e
feat: :sparkles: Create reusable workflows for deploying documentation.
beauremus f852959
docs: :memo: Add description of docs workflow usage.
beauremus 857e82f
fix: :bug: Remove extraneous backticks.
beauremus f9a277e
docs: :memo: Add context for repo config required to use Action.
beauremus d5e22b7
fix: :fire: Remove unused inputs.
beauremus 7bed0d4
fix: :bug: Add step id that's referenced in the environment.
beauremus 6ec336e
fix: :bug: Typo in id.
beauremus d73e0f4
refactor: :art: Remove redundant url and id from deploy workflows
beauremus 4e0835f
Add read permission for repo contents in workflow
beauremus fc9f89e
Add permissions for GitHub Pages deployment
beauremus 3e98f98
Add recursive pull for repos with git submodules and configuration fo…
jacob-curley-fnal 75e45bf
Update install command to include package update
jacob-curley-fnal 6e7454e
Update GitHub Actions workflow for Rust docs
jacob-curley-fnal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Deploy Source Reference Documentation | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pull-git-submodules: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: 'Indicates whether this repository has Git submodules to pull.' | ||
|
|
||
| permissions: | ||
| pages: write # Needed to deploy to GitHub Pages | ||
| id-token: write # Needed for the deploy step | ||
| contents: read # Can't see repo contents without this | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: ${{ inputs.pull-git-submodules && 'recursive' || 'false' }} | ||
|
|
||
| - name: Setup Dart | ||
| uses: dart-lang/setup-dart@v1 | ||
|
|
||
| - name: Install dartdoc | ||
| run: dart pub global activate dartdoc | ||
|
|
||
| - name: Generate Dart Docs | ||
| # Output goes to `doc/api/` | ||
| run: dart pub global run dartdoc | ||
|
|
||
| - name: Move Docs to a Standard Location | ||
| run: | | ||
| mkdir -p ./docs/reference | ||
| cp -r doc/api/* ./docs/reference | ||
|
|
||
| - name: Upload Pages Artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: './docs' | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| uses: actions/deploy-pages@v4 | ||
|
|
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| name: Deploy Source Reference Documentation | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pull-git-submodules: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: 'Indicates whether this repository has Git submodules to pull.' | ||
| references-internal-git-repo: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: 'Indicates whether this repository has a dependency in its Cargo.toml that comes from an internal GitHub repo' | ||
| static-dependencies: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: 'A space-delimited list of packages that must be installed on the machine for the code to compile' | ||
|
|
||
| permissions: | ||
| pages: write # Needed to deploy | ||
| id-token: write # Needed for auth | ||
| contents: read # Can't see repo contents without this | ||
|
|
||
| jobs: | ||
| build: | ||
|
jacob-curley-fnal marked this conversation as resolved.
|
||
| runs-on: ubuntu-latest | ||
| env: | ||
| CARGO_NET_GIT_FETCH_WITH_CLI: ${{ inputs.references-internal-git-repo }} | ||
|
|
||
| steps: | ||
| - if: ${{ inputs.static-dependencies }} | ||
| name: Install static packages | ||
| run: sudo apt-get update -y && sudo apt-get install -y ${{ inputs.static-dependencies }} | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| submodules: ${{ inputs.pull-git-submodules && 'recursive' || 'false' }} | ||
|
|
||
| - if: ${{ inputs.references-internal-git-repo }} | ||
| name: Generate a token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| app-id: ${{ vars.ACTION_SETTINGS_APP_ID }} | ||
| private-key: ${{ secrets.ACTION_SETTINGS_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - if: ${{ inputs.references-internal-git-repo }} | ||
| name: Configure Git for private repo access | ||
| run: | | ||
| git config --global url."https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/".insteadOf "https://github.com/" | ||
|
|
||
| - name: Pull from dependency cache | ||
| uses: actions/cache@v5 | ||
| continue-on-error: false | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
|
||
| - name: Generate Rust Docs | ||
| # Output goes to `target/doc/` | ||
| run: cargo doc --no-deps --all-features | ||
|
|
||
| - name: Consolidate Documentation | ||
| run: | | ||
| mkdir -p ./docs/reference | ||
| cp -r target/doc/* ./docs/reference | ||
|
|
||
| - name: Upload Pages Artifact | ||
| uses: actions/upload-pages-artifact@v4 | ||
| with: | ||
| path: './docs' | ||
|
|
||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| uses: actions/deploy-pages@v4 | ||
|
|
||
This file contains hidden or 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 +1,24 @@ | ||
| # .github | ||
| # .github | ||
|
|
||
| ## How to use reusable workflows | ||
|
|
||
| [GitHub workflows](https://docs.github.com/en/actions/how-tos/write-workflows) are installed in the `.github/workflows` directory of your repo. See example installations below. | ||
|
|
||
| ### Documentation workflows | ||
|
|
||
| _Note_: Using this requires some setup in your repo. See the [docs](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow) | ||
|
|
||
| ```yaml | ||
| name: Documentation Deployment | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| deploy-docs: | ||
| uses: ./.github/workflows/deploy-<lang>-docs.yaml@main | ||
| secrets: inherit | ||
| ``` | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need a
contents: readentry as well. I'm getting errors when trying to call this, as default behavior is to only set the permissions that are provided here, and to try to use the lowest level permissions possible. My suspicion is that GitHub sees this as us "downgrading" the permissions from the calling workflow, sincereadis not specified. So it's dropping the read permissions and can't see the code in the repo anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will apply to all workflows. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any workflow that specifies permissions at this level, yes. The integration and deployment workflows just expect to have their permissions provided. They don't have any special
permissionsblock like this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got a successful deployment! Only problem is that the permissions on the pages site are jank, so I can't access the actual docs 😆 Might be a problem at the repo level tho, or with the org permissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out the best way to consistently handle the URLs. I found the docs here https://studious-spoon-gz98yym.pages.github.io/reference/rust_env_var_lib/index.html 😅
Not great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out how to resolve the snake case package name for this step:
It should be