Merge pull request #669 from Mercy017/feat/web-push-notifications-619 #27
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
| name: Deploy Contract API Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pages_enabled: ${{ steps.pages_check.outputs.enabled }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Check if GitHub Pages is enabled | |
| id: pages_check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| HTTP=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pages") | |
| if [ "$HTTP" = "200" ]; then | |
| echo "enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "GitHub Pages not enabled (HTTP $HTTP) — skipping docs deploy." | |
| fi | |
| - name: Set up Rust | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache cargo registry and target | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-docs- | |
| - name: Check for missing documentation on public items | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| run: | | |
| cargo doc --package trivela-campaign-contract --package trivela-rewards-contract --no-deps --document-private-items 2>&1 | tee cargo-doc-output.txt | |
| if grep -q "warning: missing documentation for" cargo-doc-output.txt; then | |
| echo "Missing documentation found!" | |
| grep "warning: missing documentation for" cargo-doc-output.txt | |
| exit 1 | |
| fi | |
| - name: Generate docs with cargo doc | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| run: | | |
| cargo doc --package trivela-campaign-contract --package trivela-rewards-contract --no-deps | |
| - name: Copy docs to docs/contract-api | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| run: | | |
| rm -rf docs/contract-api | |
| cp -r target/doc docs/contract-api | |
| - name: Setup Pages | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| if: steps.pages_check.outputs.enabled == 'true' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/contract-api | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: needs.build.outputs.pages_enabled == 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |