Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 0 additions & 13 deletions .config/dotnet-tools.json

This file was deleted.

42 changes: 0 additions & 42 deletions .devcontainer/Dockerfile

This file was deleted.

20 changes: 15 additions & 5 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Run Build Commands
# Work on the gallery in a dev container

## Build
Open the repository in a VS Code dev container or GitHub Codespaces. The container includes Node.js 22, PowerShell, GitHub CLI, and Azure CLI, and installs the gallery's locked dependencies.

From the repository root:

```shell
npm --prefix site run dev
```
docfx docfx.json --build

Open the forwarded port at `/script-samples/`. To check your changes:

```shell
npm --prefix site test
npm --prefix site run build
```

## Server
http-server -c-1
Browser tests need Chromium installed once with `npx playwright install chromium` from the `site` directory. Run them with `npm --prefix site run test:e2e`.

You do not need to build the gallery to contribute a script. Follow the [contribution guide](../docs/contributing/preparing-a-submission.md).
77 changes: 15 additions & 62 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/dotnet
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "6.0",
// Options
"NODE_VERSION": "lts/*"
}
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5001],

// [Optional] To reuse of your local HTTPS dev cert:
//
// 1. Export it locally using this command:
// * Windows PowerShell:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
// * macOS/Linux terminal:
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
//
// 2. Uncomment these 'remoteEnv' lines:
// "remoteEnv": {
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
// },
//
// 3. Do one of the following depending on your scenario:
// * When using GitHub Codespaces and/or Remote - Containers:
// 1. Start the container
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
//
// * If only using Remote - Containers with a local container, uncomment this line instead:
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"github-cli": "latest",
"azure-cli": "latest",
"powershell": "latest"
},
"postCreateCommand": "/bin/bash ./.devcontainer/post-create.sh"
"name": "Community Script Samples",
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {}
},
"customizations": {
"vscode": {
"extensions": ["astro-build.astro-vscode", "ms-vscode.PowerShell"]
}
},
"forwardPorts": [4321],
"postCreateCommand": "npm --prefix site ci",
"remoteUser": "node"
}
4 changes: 0 additions & 4 deletions .devcontainer/post-create.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .devcontainer/setup.sh

This file was deleted.

18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## What does this change help someone do?

Describe the scenario or improvement, and link to any related issue.

## How did you test it?

Include tool versions, the expected result, and any limitations. Do not include credentials, tenant IDs, or personal data.

## For new or updated samples

- [ ] The README explains prerequisites, permissions, and the expected result.
- [ ] Each advertised tool tab contains a complete, tested script.
- [ ] Destructive actions have a clear impact warning before the script.
- [ ] Metadata, author attribution, tested tool versions, and the preview are accurate.
- [ ] No template placeholders or private tenant details remain.
- [ ] The final README tracker points to this sample.

Need a hand? See the [contribution guide](../docs/contributing/preparing-a-submission.md). Every sample contributor is eligible for the [contributor badge](../docs/contributing/recognition.md) after their first accepted sample and recognition-program opt-in.
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
- A sample requires `README.md`, `assets/sample.json`, and `assets/preview.png`. The README screenshot is optional; the template includes `assets/example.png`. If scaffolding manually, copy `assets/template.sample.json` to `assets/sample.json` and fill in its metadata.
- Remove credentials, usernames, and tenant-specific details from sample scripts. For scripts that delete or remove data, add a clear warning describing the impact before the script.
- The final line of every script-root `README.md` must be the visitor-tracking image. Set its `src` to `https://m365-visitor-stats.azurewebsites.net/script-samples/{script-path}`, replacing `{script-path}` with the repository-relative sample directory, for example `scripts/spo-get-list-items`. Preserve existing attributes such as `aria-hidden` when present.
- For the full submission workflow and requirements, see the [contribution guide](../docfx/contributing/preparing-a-submission.md). For scaffolding an existing script submission, follow the [sample-scaffolder skill](skills/sample-scaffolder/SKILL.md).
- For the full submission workflow and requirements, see the [contribution guide](../docs/contributing/preparing-a-submission.md). For scaffolding an existing script submission, follow the [sample-scaffolder skill](skills/sample-scaffolder/SKILL.md).
87 changes: 87 additions & 0 deletions .github/schemas/sample.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://pnp.github.io/script-samples/schemas/sample.schema.json",
"title": "Community Script Samples metadata",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "source", "title", "shortDescription", "url", "longDescription", "creationDateTime", "updateDateTime", "products", "metadata", "categories", "tags", "thumbnails", "authors", "references"],
"properties": {
"schema": { "type": ["string", "null"] },
"version": { "type": ["string", "null"] },
"name": { "type": "string", "minLength": 1, "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$" },
"source": { "const": "pnp" },
"title": { "type": "string", "minLength": 1, "pattern": "\\S" },
"shortDescription": { "type": "string", "minLength": 1, "pattern": "\\S" },
"url": { "type": "string", "format": "uri" },
"longDescription": { "type": "array", "items": { "type": "string" } },
"creationDateTime": { "type": "string", "format": "date" },
"updateDateTime": { "type": "string", "format": "date" },
"products": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
"metadata": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["key", "value"],
"properties": {
"key": { "enum": ["PNP-POWERSHELL", "CLI-FOR-MICROSOFT365", "GRAPH-POWERSHELL", "SPO-MANAGEMENT-SHELL", "POWERSHELL", "AZURE-CLI", "POWERAPPS-POWERSHELL", "MICROSOFTTEAMS-POWERSHELL", "MICROSOFTWHITEBOARDADMIN", "JAVASCRIPT", "BASH", "GITHUB", "PYTHON"] },
"value": { "type": "string", "minLength": 1, "pattern": "\\S" }
}
}
},
"categories": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "enum": ["Modernize", "Data", "Deploy", "Provision", "Configure", "Report", "Security", "AI", "Microsoft Copilot"] } },
"tags": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
"thumbnails": {
"type": "array",
"minItems": 1,
"contains": { "type": "object", "required": ["type"], "properties": { "type": { "const": "image" } } },
"items": {
"type": "object",
"additionalProperties": false,
"required": ["type", "order", "url", "alt"],
"properties": {
"name": { "type": "string" },
"type": { "enum": ["image", "video"] },
"order": { "type": "integer", "minimum": 0 },
"url": { "type": "string", "format": "uri" },
"alt": { "type": "string", "minLength": 1, "pattern": "\\S" }
}
}
},
"authors": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["gitHubAccount", "name", "pictureUrl"],
"properties": {
"gitHubAccount": { "type": "string", "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$" },
"name": { "type": "string", "minLength": 1, "pattern": "\\S" },
"pictureUrl": { "type": "string", "format": "uri" },
"company": { "type": "string" },
"twitter": { "type": "string" }
}
}
},
"references": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "description", "url"],
"properties": {
"name": { "type": "string", "minLength": 1 },
"description": { "type": "string" },
"url": { "type": "string", "format": "uri" }
}
}
}
}
}
}
1 change: 1 addition & 0 deletions .github/skills/sample-scaffolder/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ This skill should
- Ensure the script-root README.md ends with the current tracking image and replace `{script-path}` with a path such as `scripts/my-sample`.
- Copy the template.sample.json file to the assets folder and rename it to sample.json. It should then fill in the relevant information from the sample submission into the sample.json file.
- Copy the sample image to the assets folder.
- Validate the completed submission with `npm --prefix site run validate:samples`. The Astro gallery uses the sample README and metadata directly; shared documentation includes live under `docs/includes`.
87 changes: 87 additions & 0 deletions .github/workflows/deploy-gallery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Deploy gallery

on:
push:
branches: [main]
workflow_dispatch:

permissions: {}

concurrency:
group: github-pages
cancel-in-progress: true

jobs:
build:
if: github.repository == 'pnp/script-samples'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
defaults:
run:
working-directory: site
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22.19.0"
cache: npm
cache-dependency-path: site/package-lock.json
- name: Install dependencies
run: npm ci
- name: Test catalog and sample generator
run: npm test
- name: Test generator
shell: pwsh
run: ./tests/generator.ps1
- name: Build and validate production gallery
run: npm run build
env:
PUBLIC_COMMIT_SHA: ${{ github.sha }}
PUBLIC_ENABLE_VIEW_TRACKING: "true"
- name: Install Chromium
run: npx playwright install --with-deps chromium
- name: Test release
run: npm run test:e2e
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: site/dist

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
- name: Verify published commit
shell: pwsh
env:
SITE_URL: ${{ steps.deployment.outputs.page_url }}
EXPECTED_COMMIT: ${{ github.sha }}
run: |
$ErrorActionPreference = 'Stop'
$baseUrl = $env:SITE_URL.TrimEnd('/')
for ($attempt = 1; $attempt -le 12; $attempt++) {
try {
$marker = Invoke-RestMethod "$baseUrl/deployment.json"
$home = Invoke-WebRequest "$baseUrl/"
if ($marker.commit -ne $env:EXPECTED_COMMIT) { throw 'Deployed commit does not match this workflow.' }
if ($home.Content -notmatch '<title>Community Script Samples</title>') { throw 'The gallery home page was not deployed.' }
Write-Host "Verified $baseUrl at commit $env:EXPECTED_COMMIT with $($marker.sampleCount) samples."
exit 0
} catch {
if ($attempt -eq 12) { throw }
Start-Sleep -Seconds 10
}
}
Loading
Loading