Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/deploy-dart-docs.yaml
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

90 changes: 90 additions & 0 deletions .github/workflows/deploy-rust-docs.yaml
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
Comment on lines +22 to +24
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need a contents: read entry 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, since read is not specified. So it's dropping the read permissions and can't see the code in the repo anymore.

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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 permissions block like this.

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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:

cp -r target/doc/* ./docs/reference

It should be

cp -r target/doc/rust_env_var_lib/* ./docs/

contents: read # Can't see repo contents without this

jobs:
build:
Comment thread
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

25 changes: 24 additions & 1 deletion README.md
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
```