Rehash github workflow PR management

import/copybara status checks cannot trigger workflows, so we need to poll for them instead.
Rehash management of imported PRs to support this. When the import is successful, github actions will comment on the
PR with a link to Gerrit. After the CL merges on Gerrit and is pushed back to Github, the PR will be automatically closed.

This is an imported pull request from
https://github.com/google/dawn/pull/9

GITHUB_PR_HEAD_SHA=9aabe4663503b6aeef832b2de2c5aafbcd73ce8c
ORIGINAL_AUTHOR=Austin Eng <2154796+austinEng@users.noreply.github.com>
GitOrigin-RevId: 927bdc938f74e23a92f4fdd6b3b3c11d5443c883
Change-Id: Iacc6a9ca3e768b1d936eae0fe7c259dfd1771cc1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/159022
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/.github/workflows/pr-manager.yml b/.github/workflows/pr-manager.yml
new file mode 100644
index 0000000..eac4ada
--- /dev/null
+++ b/.github/workflows/pr-manager.yml
@@ -0,0 +1,60 @@
+# Sub-workflow to manage commenting on and closing PRs.
+name: PR Manager
+
+on:
+  workflow_dispatch:
+    inputs:
+      pullNumber:
+        type: number
+        required: true
+      state:
+        type: string
+        required: true
+      targetUrl:
+        type: string
+
+jobs:
+  imported:
+    name: PR Imported
+    if: inputs.state == 'success' || inputs.state == 'SUCCESS'
+    runs-on: ubuntu-latest
+    permissions:
+      pull-requests: write
+    steps:
+    - uses: marocchino/sticky-pull-request-comment@v2
+      with:
+        number: ${{ inputs.pullNumber }}
+        header: pr_was_imported # key to reuse the same comment
+        skip_unchanged: true
+        message: |
+          👋 Thanks for your contribution! Your PR has been imported to Gerrit.
+          Please visit ${{ inputs.targetUrl }} to see it and CC yourself on the change.
+          After iterating on feedback, please comment on the Gerrit review to notify reviewers.
+          All reviews are handled within Gerrit, any comments on the GitHub PR may be missed.
+          You can continue to upload commits to this PR, and they will be automatically imported
+          into Gerrit.
+
+  merged:
+    name: PR Merged
+    if: inputs.state == 'merged' || inputs.state == 'MERGED'
+    runs-on: ubuntu-latest
+    permissions:
+      pull-requests: write
+    steps:
+    - uses: marocchino/sticky-pull-request-comment@v2
+      with:
+        number: ${{ inputs.pullNumber }}
+        header: pr_was_merged # key to reuse the same comment
+        skip_unchanged: true
+        message: 🚀 PR was merged in ${{ inputs.targetUrl }}!
+
+    - name: Close PR
+      uses: actions/github-script@v6
+      with:
+        script: |
+          await github.rest.pulls.update({
+            owner: context.repo.owner,
+            repo: context.repo.repo,
+            pull_number: ${{ inputs.pullNumber }},
+            state: 'closed',
+          });