Arthur: Add tf-github-autoresponse.yaml

Test github auto response job

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I3fc4ab5316dea82b56ddd80b33b5542b656ea009
diff --git a/ci/arthur-she_issue_comment.md b/ci/arthur-she_issue_comment.md
new file mode 100644
index 0000000..fb4d721
--- /dev/null
+++ b/ci/arthur-she_issue_comment.md
@@ -0,0 +1,15 @@
+Hello @{user_name}!
+
+
+Thank you for raising an issue for **Trusted Firmware-A**.
+
+The TF-A project has now migrated to www.trustedfirmware.org. This issue tracker will still remain accessible for some time, but only for historical reasons. From now on you should raise new issues on trustedfirmware.org.
+
+If it is a query or a design discussion it is better discussed via the [mailing list](https://lists.trustedfirmware.org/mailman/listinfo/tf-a). If it is issue/bug which need to be tracked, raise an issue in the [issue tracking board](https://developer.trustedfirmware.org/maniphest/query/open/) and also send an email to the [mailing list](https://lists.trustedfirmware.org/mailman/listinfo/tf-a) to notify the TF-A community.
+
+## How do I raise issues for TF-A?
+Please use our new [issue tracking board](https://developer.trustedfirmware.org/maniphest/query/open/). For this you just need to login with your existing GitHub account. We also have a [guide](https://developer.trustedfirmware.org/dashboard/view/6/) to help you raise the issue with the appropriate labels and tags. This way it will be easier for both you and us to track and address the issue most effectively.
+
+We are looking forward to seeing you in trustedfirmware.org!
+
+The **Trusted Firmware-A** team
\ No newline at end of file
diff --git a/ci/arthur-she_pr_comment.md b/ci/arthur-she_pr_comment.md
new file mode 100644
index 0000000..0418224
--- /dev/null
+++ b/ci/arthur-she_pr_comment.md
@@ -0,0 +1,24 @@
+Hello @{user_name}!
+
+
+Thank you for your contribution to **Trusted Firmware-A**!
+
+The TF-A project has now migrated to www.trustedfirmware.org. Our GitHub repo will remain accessible as a Read-Only mirror but we have changed the way we accept contributions for the project.
+
+## How do I contribute patches to TF-A?
+We have a [Getting started](https://developer.trustedfirmware.org/w/tf_a/gerrit-getting-started/) article which we hope will make everything very straightforward! And if you would like more details you can always refer to the [contributing guidelines](https://trustedfirmware-a.readthedocs.io/en/latest/process/contributing.html).
+
+A quick overview:
+1. Go to review.trustedfirmware.org
+2. Register with your existing GitHub account
+3. Submit your patches!
+
+## What if I face any problems?
+We have many channels through which you can contact us:
+
+ * **Our mailing lists**
+   You can send us an email in the [public TF-A mailing list](https://lists.trustedfirmware.org/mailman/listinfo/tf-a). [Here](https://lists.trustedfirmware.org/mailman/listinfo) you can also find all the mailing lists for all the projects hosted under trustedfirmware.org.
+
+We are looking forward to seeing your patch submitted to trustedfirmware.org!
+
+The **Trusted Firmware-A** team
diff --git a/ci/github_autoreply_bot.py b/ci/github_autoreply_bot.py
new file mode 100755
index 0000000..f6af2c8
--- /dev/null
+++ b/ci/github_autoreply_bot.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+import argparse
+import datetime
+import sys
+import os.path
+import logging
+
+try:
+    from github import Github
+    from github import Auth
+except ImportError:
+    print(
+        "Can not import from github. PyGitHub may be missing. Check requirements.txt."
+    )
+    sys.exit(1)
+
+SCRIPT_DIR = os.path.dirname(__file__)
+
+
+def readfile(path):
+    """Read a file into a python string"""
+    try:
+        with open(os.path.join(SCRIPT_DIR, path), "r") as textfile:
+            comment = textfile.read()
+    except FileNotFoundError:
+        print(f"Can not fine comment template file \"{path}\"")
+        sys.exit(1)
+    else:
+        return comment 
+
+
+def reply_to_issue(repo, issue_num):
+    """Reply to new issues"""
+    comment_file = f"{repo.owner.login}_issue_comment.md"
+    issue = repo.get_issue(number = issue_num)
+    body = readfile(comment_file)
+    issue.create_comment(body.format(user_name=issue.user.login))
+
+
+def reply_to_pr(repo, pr_num):
+    """Reply to new Pull Request"""
+    comment_file = f"{repo.owner.login}_pr_comment.md"
+    pr = repo.get_pull(number = pr_num)
+    body = readfile(comment_file)
+    pr.create_issue_comment(body.format(user_name=pr.user.login))
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--token", required=True, help="GitHub access token")
+    parser.add_argument("--repo", required=True, help="GitHub repository")
+    group = parser.add_mutually_exclusive_group()
+    group.add_argument("--issue_num", type=int, help="Github issue number")
+    group.add_argument("--pr_num", type=int, help="Github pull reuqest number")
+    args = parser.parse_args()
+
+    auth = Auth.Token(args.token)
+    gh = Github(auth=auth)
+
+    try:
+        repo = gh.get_repo(args.repo)
+    except:
+        print(f"Can not get Github repo {args.repo}")
+        sys.exit(1)
+
+    if args.issue_num:
+        reply_to_issue(repo, args.issue_num)
+    if args.pr_num:
+        reply_to_pr(repo, args.pr_num)
diff --git a/ci/requirements.txt b/ci/requirements.txt
new file mode 100644
index 0000000..5aeecd4
--- /dev/null
+++ b/ci/requirements.txt
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+#github_pr_bot.py requires:
+
+pygithub>=1.44
diff --git a/ci/run_github_autoreply.sh b/ci/run_github_autoreply.sh
new file mode 100755
index 0000000..a6d19ed
--- /dev/null
+++ b/ci/run_github_autoreply.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Install PyGitHub if needed
+python3 -c "import github"
+if [ $? != 0 ]
+then
+	yes | pip3 install pygithub
+fi
+
+# Run bot
+if [ -z ${github_issue_num} -a -z ${github_pr_num} ]; then
+    echo "We need one of github_issue_num or github_pr_num"
+    exit 1
+fi
+opts="--token ${OPENCI_BOT_GITHUB_TOKEN} --repo ${github_repo_full_name}"
+[ -n ${github_issue_num} ] && opts="${opts} --issue_num ${github_issue_num}"
+[ -n ${github_pr_num} ] && opts="${opts} --pr_num ${github_pr_num}"
+python3 $(dirname "${BASH_SOURCE[0]}")/github_autoreply_bot.py ${opts}
diff --git a/tf-github-autoresponse.yaml b/tf-github-autoresponse.yaml
new file mode 100644
index 0000000..5365ece
--- /dev/null
+++ b/tf-github-autoresponse.yaml
@@ -0,0 +1,41 @@
+- job:
+    block-downstream: false
+    block-upstream: false
+    disabled: false
+    name: tf-github-autoresponse
+    display-name: 'TF Github auto response'
+    project-type: freestyle
+    node: master
+    builders:
+    - shell: |-
+        #!/bin/bash
+        echo "########################################################################"
+        echo "    Github Environment"
+        env |grep '^github_'
+        echo "########################################################################"
+        bash tf-ci-scripts/ci/run_github_autoreply.sh
+    properties:
+    - build-discarder:
+        days-to-keep: 30
+        num-to-keep: 100
+    scm:
+    - git:
+        branches:
+        - master
+        clean:
+          before: true
+        url: https://review.trustedfirmware.org/next/ci/tf-ci-scripts
+        basedir: tf-ci-script
+    triggers:
+    - generic-webhook-trigger:
+        post-content-params:
+            - type: JSONPath
+              key: github_repo_full_name
+              value: $.repository.full_name
+            - type: JSONPath
+              key: github_issue_num 
+              value: $.issue.number
+            - type: JSONPath
+              key: github_pr_num
+              value: $.pull_request.number
+        token: trustedfirmware_github_auto_response