diff --git a/.github/scripts/welcome-first-time-contributor.js b/.github/scripts/welcome-first-time-contributor.js
new file mode 100644
index 00000000..a1e40a33
--- /dev/null
+++ b/.github/scripts/welcome-first-time-contributor.js
@@ -0,0 +1,71 @@
+
+const core = require('@actions/core');
+const github = require('@actions/github');
+
+async function run() {
+ const context = github.context;
+
+ const issueMessage = `Welcome to Accord. Thanks a lot for reporting your first issue. Please check out our [contributors guide](https://github.com/accordproject/techdocs/blob/main/CONTRIBUTING.md).
Keep in mind there are also other channels you can use to interact with the Accord community. For more details check out our [Discord](https://discord.com/invite/Zm99SKhhtA).`;
+
+ const prMessage = `Welcome to Accord. Thanks a lot for creating your first pull request. Please check out our [contributors guide](https://github.com/accordproject/techdocs/blob/main/CONTRIBUTING.md).
Keep in mind there are also other channels you can use to interact with the Accord community. For more details check out our [Discord](https://discord.com/invite/Zm99SKhhtA).`;
+ let token=process.env.GITHUB_TOKEN;
+ const octokit = github.getOctokit(token);
+ const isIssue = !!context.payload.issue;
+ let isFirstContribution;
+
+ if (isIssue) {
+ const query = `query($owner:String!, $name:String!, $contributer:String!) {
+ repository(owner:$owner, name:$name){
+ issues(first: 1, filterBy: {createdBy:$contributer}){
+ totalCount
+ }
+ }
+ }`;
+ const variables = {
+ owner: context.repo.owner,
+ name: context.repo.repo,
+ contributer: context.payload.sender.login
+ };
+ const { repository: { issues: { totalCount } } } = await octokit.graphql(query, variables);
+ isFirstContribution = totalCount === 1;
+ } else {
+ const query = `query($qstr: String!) {
+ search(query: $qstr, type: ISSUE, first: 1) {
+ issueCount
+ }
+ }`;
+ const variables = {
+ qstr: `repo:${context.repo.owner}/${context.repo.repo} type:pr author:${context.payload.sender.login}`,
+ };
+ const { search: { issueCount } } = await octokit.graphql(query, variables);
+ isFirstContribution = issueCount === 1;
+ }
+
+ if (!isFirstContribution) {
+ console.log(`Not the user's first contribution.`);
+ return;
+ }
+
+ const message = isIssue ? issueMessage : prMessage;
+
+ if (isIssue) {
+ const issueNumber = context.payload.issue.number;
+ await octokit.rest.issues.createComment({
+ owner: context.payload.repository.owner.login,
+ repo: context.payload.repository.name,
+ issue_number: issueNumber,
+ body: message
+ });
+ } else {
+ const pullNumber = context.payload.pull_request.number;
+ await octokit.rest.pulls.createReview({
+ owner: context.payload.repository.owner.login,
+ repo: context.payload.repository.name,
+ pull_number: pullNumber,
+ body: message,
+ event: 'COMMENT'
+ });
+ }
+}
+
+run().catch(err => core.setFailed(err.message));
diff --git a/.github/workflows/welcome-first-time-contributor.yml b/.github/workflows/welcome-first-time-contributor.yml
new file mode 100644
index 00000000..6f1c403d
--- /dev/null
+++ b/.github/workflows/welcome-first-time-contributor.yml
@@ -0,0 +1,33 @@
+name: Welcome first time contributors
+
+on:
+ pull_request_target:
+ types:
+ - opened
+ issues:
+ types:
+ - opened
+
+jobs:
+ welcome:
+ name: Post welcome message
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [18.x]
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node-version }}
+ - name: NPM Install
+ run: npm install
+
+ - name: Run welcome script
+ run: node .github/scripts/welcome-first-time-contributor.js
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
diff --git a/package-lock.json b/package-lock.json
index beeb0ee6..574447f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,6 +13,8 @@
"@accordproject/markdown-template": "^0.16.19",
"@accordproject/markdown-transform": "^0.16.19",
"@accordproject/template-engine": "^2.3.5",
+ "@actions/core": "^1.11.1",
+ "@actions/github": "^6.0.0",
"@ant-design/icons": "^5.3.7",
"@monaco-editor/react": "^4.6.0",
"@types/styled-components": "^5.1.34",
@@ -1089,6 +1091,53 @@
"node": ">=4.2.0"
}
},
+ "node_modules/@actions/core": {
+ "version": "1.11.1",
+ "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
+ "integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
+ "license": "MIT",
+ "dependencies": {
+ "@actions/exec": "^1.1.1",
+ "@actions/http-client": "^2.0.1"
+ }
+ },
+ "node_modules/@actions/exec": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
+ "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
+ "license": "MIT",
+ "dependencies": {
+ "@actions/io": "^1.0.1"
+ }
+ },
+ "node_modules/@actions/github": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz",
+ "integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==",
+ "license": "MIT",
+ "dependencies": {
+ "@actions/http-client": "^2.2.0",
+ "@octokit/core": "^5.0.1",
+ "@octokit/plugin-paginate-rest": "^9.0.0",
+ "@octokit/plugin-rest-endpoint-methods": "^10.0.0"
+ }
+ },
+ "node_modules/@actions/http-client": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz",
+ "integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==",
+ "license": "MIT",
+ "dependencies": {
+ "tunnel": "^0.0.6",
+ "undici": "^5.25.4"
+ }
+ },
+ "node_modules/@actions/io": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz",
+ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==",
+ "license": "MIT"
+ },
"node_modules/@adobe/css-tools": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.3.tgz",
@@ -3753,6 +3802,15 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
+ "node_modules/@fastify/busboy": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
+ "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=14"
+ }
+ },
"node_modules/@floating-ui/core": {
"version": "1.6.6",
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.6.tgz",
@@ -4151,6 +4209,164 @@
"node": ">= 8"
}
},
+ "node_modules/@octokit/auth-token": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
+ "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/core": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.1.tgz",
+ "integrity": "sha512-dKYCMuPO1bmrpuogcjQ8z7ICCH3FP6WmxpwC03yjzGfZhj9fTJg6+bS1+UAplekbN2C+M61UNllGOOoAfGCrdQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/auth-token": "^4.0.0",
+ "@octokit/graphql": "^7.1.0",
+ "@octokit/request": "^8.4.1",
+ "@octokit/request-error": "^5.1.1",
+ "@octokit/types": "^13.0.0",
+ "before-after-hook": "^2.2.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/endpoint": {
+ "version": "9.0.6",
+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.6.tgz",
+ "integrity": "sha512-H1fNTMA57HbkFESSt3Y9+FBICv+0jFceJFPWDePYlR/iMGrwM5ph+Dd4XRQs+8X+PUFURLQgX9ChPfhJ/1uNQw==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/types": "^13.1.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/graphql": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.1.1.tgz",
+ "integrity": "sha512-3mkDltSfcDUoa176nlGoA32RGjeWjl3K7F/BwHwRMJUW/IteSa4bnSV8p2ThNkcIcZU2umkZWxwETSSCJf2Q7g==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/request": "^8.4.1",
+ "@octokit/types": "^13.0.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/openapi-types": {
+ "version": "24.2.0",
+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-24.2.0.tgz",
+ "integrity": "sha512-9sIH3nSUttelJSXUrmGzl7QUBFul0/mB8HRYl3fOlgHbIWG+WnYDXU3v/2zMtAvuzZ/ed00Ei6on975FhBfzrg==",
+ "license": "MIT"
+ },
+ "node_modules/@octokit/plugin-paginate-rest": {
+ "version": "9.2.2",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.2.tgz",
+ "integrity": "sha512-u3KYkGF7GcZnSD/3UP0S7K5XUFT2FkOQdcfXZGZQPGv3lm4F2Xbf71lvjldr8c1H3nNbF+33cLEkWYbokGWqiQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/types": "^12.6.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "peerDependencies": {
+ "@octokit/core": "5"
+ }
+ },
+ "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/openapi-types": {
+ "version": "20.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz",
+ "integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==",
+ "license": "MIT"
+ },
+ "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": {
+ "version": "12.6.0",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz",
+ "integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/openapi-types": "^20.0.0"
+ }
+ },
+ "node_modules/@octokit/plugin-rest-endpoint-methods": {
+ "version": "10.4.1",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz",
+ "integrity": "sha512-xV1b+ceKV9KytQe3zCVqjg+8GTGfDYwaT1ATU5isiUyVtlVAO3HNdzpS4sr4GBx4hxQ46s7ITtZrAsxG22+rVg==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/types": "^12.6.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "peerDependencies": {
+ "@octokit/core": "5"
+ }
+ },
+ "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": {
+ "version": "20.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-20.0.0.tgz",
+ "integrity": "sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==",
+ "license": "MIT"
+ },
+ "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": {
+ "version": "12.6.0",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.6.0.tgz",
+ "integrity": "sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/openapi-types": "^20.0.0"
+ }
+ },
+ "node_modules/@octokit/request": {
+ "version": "8.4.1",
+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.4.1.tgz",
+ "integrity": "sha512-qnB2+SY3hkCmBxZsR/MPCybNmbJe4KAlfWErXq+rBKkQJlbjdJeS85VI9r8UqeLYLvnAenU8Q1okM/0MBsAGXw==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/endpoint": "^9.0.6",
+ "@octokit/request-error": "^5.1.1",
+ "@octokit/types": "^13.1.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/request-error": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.1.1.tgz",
+ "integrity": "sha512-v9iyEQJH6ZntoENr9/yXxjuezh4My67CBSu9r6Ve/05Iu5gNgnisNWOsoJHTP6k0Rr0+HQIpnH+kyammu90q/g==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/types": "^13.1.0",
+ "deprecation": "^2.0.0",
+ "once": "^1.4.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/types": {
+ "version": "13.10.0",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz",
+ "integrity": "sha512-ifLaO34EbbPj0Xgro4G5lP5asESjwHracYJvVaPIyXMuiuXLlhic3S47cBdTb+jfODkTE5YtGCLt3Ay3+J97sA==",
+ "license": "MIT",
+ "dependencies": {
+ "@octokit/openapi-types": "^24.2.0"
+ }
+ },
"node_modules/@openapi-contrib/openapi-schema-to-json-schema": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@openapi-contrib/openapi-schema-to-json-schema/-/openapi-schema-to-json-schema-3.2.0.tgz",
@@ -8937,6 +9153,12 @@
}
]
},
+ "node_modules/before-after-hook": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
+ "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==",
+ "license": "Apache-2.0"
+ },
"node_modules/bl": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
@@ -10388,6 +10610,12 @@
"node": ">= 0.8"
}
},
+ "node_modules/deprecation": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
+ "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==",
+ "license": "ISC"
+ },
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
@@ -21505,6 +21733,15 @@
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
"integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw=="
},
+ "node_modules/tunnel": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
+ "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.6.11 <=0.7.0 || >=0.7.3"
+ }
+ },
"node_modules/type": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
@@ -21584,6 +21821,18 @@
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz",
"integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw=="
},
+ "node_modules/undici": {
+ "version": "5.29.0",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz",
+ "integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==",
+ "license": "MIT",
+ "dependencies": {
+ "@fastify/busboy": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=14.0"
+ }
+ },
"node_modules/undici-types": {
"version": "6.13.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz",
@@ -21775,6 +22024,12 @@
"url": "https://opencollective.com/unified"
}
},
+ "node_modules/universal-user-agent": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz",
+ "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==",
+ "license": "ISC"
+ },
"node_modules/universalify": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
diff --git a/package.json b/package.json
index a556a24f..e200f2eb 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,8 @@
"@accordproject/markdown-template": "^0.16.19",
"@accordproject/markdown-transform": "^0.16.19",
"@accordproject/template-engine": "^2.3.5",
+ "@actions/core": "^1.11.1",
+ "@actions/github": "^6.0.0",
"@ant-design/icons": "^5.3.7",
"@monaco-editor/react": "^4.6.0",
"@types/styled-components": "^5.1.34",