diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53c95f2..f673ea3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,11 +11,16 @@ jobs: name: Check proposals.json and generated Markdown runs-on: ubuntu-latest permissions: - contents: read + contents: write steps: - name: Checkout uses: actions/checkout@v7 + with: + # For same-repo PRs, check out the actual PR branch (head_ref) so CI + # can push commits to it; for fork PRs and pushes, use github.ref. + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref || github.ref }} + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v7 @@ -25,5 +30,23 @@ jobs: - name: Install jsonschema run: pip install jsonschema - - name: Validate proposals.json and check that Markdown files are up to date - run: python generate_markdown.py --check + - name: Validate proposals.json and check or update Markdown files + env: + IS_SAME_REPO_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + BASE_REF: ${{ github.base_ref }} + run: | + # For same-repo PRs that don't modify any of the Markdown files, + # regenerate the Markdown files and commit any updates to the PR branch. + # Otherwise, run --check so we don't clobber manual Markdown edits. + if [ "$IS_SAME_REPO_PR" = "true" ] && git diff --quiet "origin/${BASE_REF}...HEAD" -- '*.md'; then + python generate_markdown.py + if ! git diff --quiet -- '*.md'; then + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git add '*.md' + git commit -m 'Regenerate Markdown files from proposals.json' + git push + fi + else + python generate_markdown.py --check + fi diff --git a/howto.md b/howto.md index a9062e9..282a527 100644 --- a/howto.md +++ b/howto.md @@ -168,6 +168,8 @@ Add the proposal to the list of active proposals by creating a respective PR. 4. Commit `proposals.json` and `README.md` and create a PR. +**Note:** If you have write access to `WebAssembly/proposals` and create the PR on a branch in the repo (for example, by editing `proposals.json` directly in the GitHub web UI), you can skip running `./generate_markdown.py` locally and CI will commit the regenerated Markdown files to your PR automatically. + ## Setting up CI and GitHub Pages diff --git a/proposals.json b/proposals.json index 2cc5baa..80bec0d 100644 --- a/proposals.json +++ b/proposals.json @@ -97,7 +97,7 @@ "extended-name-section": { "name": "Extended Name Section", "url": "https://github.com/WebAssembly/extended-name-section", - "phase": 2, + "phase": 3, "champions": [ "Ben Visness" ]