Mirror: The spec-compliant minimum of client-side GraphQL.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(actions): Add Discord message release hook (#29)

* Copy over discord-message action

* Update Node LTS in actions

* Add discord-message hook

* Remove node-fetch

authored by

Phil Pluckthun and committed by
GitHub
c063ef66 a2247010

+267 -2
+85
.github/actions/discord-message/action.mjs
··· 1 + import * as core from '@actions/core'; 2 + import * as github from '@actions/github'; 3 + 4 + const GITHUB_TOKEN = process.env.GITHUB_TOKEN; 5 + const WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL; 6 + 7 + const octokit = github.getOctokit(GITHUB_TOKEN); 8 + 9 + const formatBody = (input) => { 10 + const titleRe = /(?:^|\n)#+[^\n]+/g; 11 + const updatedDepsRe = /\n-\s*Updated dependencies[\s\S]+\n(\n\s+-[\s\S]+)*/gi; 12 + const markdownLinkRe = /\[([^\]]+)\]\(([^\)]+)\)/g; 13 + const creditRe = new RegExp(`Submitted by (?:undefined|${markdownLinkRe.source})`, 'ig'); 14 + const repeatedNewlineRe = /(\n[ ]*)+/g; 15 + return input 16 + .replace(titleRe, '') 17 + .replace(updatedDepsRe, '') 18 + .replace(creditRe, (_match, text, url) => { 19 + if (!text || /@kitten|@JoviDeCroock/i.test(text)) return ''; 20 + return `Submitted by [${text}](${url})`; 21 + }) 22 + .replace(markdownLinkRe, (_match, text, url) => { 23 + return `[${text}](<${url}>)`; 24 + }) 25 + .replace(repeatedNewlineRe, '\n') 26 + .trim(); 27 + }; 28 + 29 + async function getReleaseBody(name, version) { 30 + const tag = `${name}@${version}`; 31 + const result = await octokit.rest.repos.getReleaseByTag({ 32 + owner: 'urql-graphql', 33 + repo: 'urql', 34 + tag, 35 + }); 36 + 37 + const release = result.status === 200 ? result.data : undefined; 38 + if (!release || !release.body) return; 39 + 40 + const title = `:package: [${tag}](<${release.html_url}>)`; 41 + const body = formatBody(release.body); 42 + if (!body) return; 43 + 44 + return `${title}\n${body}`; 45 + } 46 + 47 + async function main() { 48 + const inputPackages = core.getInput('publishedPackages'); 49 + let packages; 50 + 51 + try { 52 + packages = JSON.parse(inputPackages); 53 + } catch (e) { 54 + console.error('invalid JSON in publishedPackages input.'); 55 + return; 56 + } 57 + 58 + // Get releases 59 + const releasePromises = packages.map((entry) => { 60 + return getReleaseBody(entry.name, entry.version); 61 + }); 62 + 63 + const content = (await Promise.allSettled(releasePromises)) 64 + .map((x) => x.status === 'fulfilled' && x.value) 65 + .filter(Boolean) 66 + .join('\n\n'); 67 + 68 + // Send message through a discord webhook or bot 69 + const response = fetch(WEBHOOK_URL, { 70 + method: 'POST', 71 + headers: { 72 + 'Content-Type': 'application/json', 73 + }, 74 + body: JSON.stringify({ content }), 75 + }); 76 + 77 + if (!response.ok) { 78 + console.log('Something went wrong while sending the discord webhook.'); 79 + return; 80 + } 81 + 82 + return response; 83 + } 84 + 85 + main().then().catch(console.error);
+9
.github/actions/discord-message/action.yml
··· 1 + name: 'Send a discord message' 2 + description: 'Send a discord message as a result of a gql.tada publish.' 3 + inputs: 4 + publishedPackages: 5 + description: > 6 + A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]` 7 + runs: 8 + using: 'node20' 9 + main: 'action.mjs'
+1 -1
.github/workflows/ci.yml
··· 20 20 - name: Setup Node 21 21 uses: actions/setup-node@v1 22 22 with: 23 - node-version: 18 23 + node-version: 20 24 24 25 25 - name: Setup pnpm 26 26 uses: pnpm/action-setup@v2.2.2
+12 -1
.github/workflows/release.yml
··· 25 25 - name: Setup Node 26 26 uses: actions/setup-node@v3 27 27 with: 28 - node-version: 18 28 + node-version: 20 29 29 30 30 - name: Setup pnpm 31 31 uses: pnpm/action-setup@v2.2.2 ··· 58 58 env: 59 59 NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 60 60 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 61 + 62 + - name: Notify discord 63 + id: discord-msg 64 + if: steps.changesets.outputs.published == 'true' 65 + uses: ./.github/actions/discord-message 66 + with: 67 + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} 68 + env: 69 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 70 + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 71 + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} 61 72 62 73 - name: Publish Prerelease 63 74 if: steps.changesets.outputs.published != 'true'
+2
package.json
··· 76 76 ] 77 77 }, 78 78 "devDependencies": { 79 + "@actions/core": "^1.10.0", 80 + "@actions/github": "^5.1.1", 79 81 "@babel/plugin-transform-block-scoping": "^7.23.4", 80 82 "@babel/plugin-transform-typescript": "^7.23.6", 81 83 "@changesets/cli": "^2.27.1",
+158
pnpm-lock.yaml
··· 12 12 specifier: ^14.0.0 || ^15.0.0 || ^16.0.0 13 13 version: 16.8.1 14 14 devDependencies: 15 + '@actions/core': 16 + specifier: ^1.10.0 17 + version: 1.10.1 18 + '@actions/github': 19 + specifier: ^5.1.1 20 + version: 5.1.1 15 21 '@babel/plugin-transform-block-scoping': 16 22 specifier: ^7.23.4 17 23 version: 7.23.4(@babel/core@7.23.9) ··· 110 116 /@aashutoshrathi/word-wrap@1.2.6: 111 117 resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} 112 118 engines: {node: '>=0.10.0'} 119 + dev: true 120 + 121 + /@actions/core@1.10.1: 122 + resolution: {integrity: sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==} 123 + dependencies: 124 + '@actions/http-client': 2.2.1 125 + uuid: 8.3.2 126 + dev: true 127 + 128 + /@actions/github@5.1.1: 129 + resolution: {integrity: sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==} 130 + dependencies: 131 + '@actions/http-client': 2.2.1 132 + '@octokit/core': 3.6.0 133 + '@octokit/plugin-paginate-rest': 2.21.3(@octokit/core@3.6.0) 134 + '@octokit/plugin-rest-endpoint-methods': 5.16.2(@octokit/core@3.6.0) 135 + transitivePeerDependencies: 136 + - encoding 137 + dev: true 138 + 139 + /@actions/http-client@2.2.1: 140 + resolution: {integrity: sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==} 141 + dependencies: 142 + tunnel: 0.0.6 143 + undici: 5.28.4 113 144 dev: true 114 145 115 146 /@ampproject/remapping@2.2.1: ··· 857 888 engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} 858 889 dev: true 859 890 891 + /@fastify/busboy@2.1.1: 892 + resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} 893 + engines: {node: '>=14'} 894 + dev: true 895 + 860 896 /@humanwhocodes/config-array@0.11.14: 861 897 resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} 862 898 engines: {node: '>=10.10.0'} ··· 992 1028 fastq: 1.17.0 993 1029 dev: true 994 1030 1031 + /@octokit/auth-token@2.5.0: 1032 + resolution: {integrity: sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==} 1033 + dependencies: 1034 + '@octokit/types': 6.41.0 1035 + dev: true 1036 + 1037 + /@octokit/core@3.6.0: 1038 + resolution: {integrity: sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==} 1039 + dependencies: 1040 + '@octokit/auth-token': 2.5.0 1041 + '@octokit/graphql': 4.8.0 1042 + '@octokit/request': 5.6.3 1043 + '@octokit/request-error': 2.1.0 1044 + '@octokit/types': 6.41.0 1045 + before-after-hook: 2.2.3 1046 + universal-user-agent: 6.0.1 1047 + transitivePeerDependencies: 1048 + - encoding 1049 + dev: true 1050 + 1051 + /@octokit/endpoint@6.0.12: 1052 + resolution: {integrity: sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==} 1053 + dependencies: 1054 + '@octokit/types': 6.41.0 1055 + is-plain-object: 5.0.0 1056 + universal-user-agent: 6.0.1 1057 + dev: true 1058 + 1059 + /@octokit/graphql@4.8.0: 1060 + resolution: {integrity: sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==} 1061 + dependencies: 1062 + '@octokit/request': 5.6.3 1063 + '@octokit/types': 6.41.0 1064 + universal-user-agent: 6.0.1 1065 + transitivePeerDependencies: 1066 + - encoding 1067 + dev: true 1068 + 1069 + /@octokit/openapi-types@12.11.0: 1070 + resolution: {integrity: sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==} 1071 + dev: true 1072 + 1073 + /@octokit/plugin-paginate-rest@2.21.3(@octokit/core@3.6.0): 1074 + resolution: {integrity: sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==} 1075 + peerDependencies: 1076 + '@octokit/core': '>=2' 1077 + dependencies: 1078 + '@octokit/core': 3.6.0 1079 + '@octokit/types': 6.41.0 1080 + dev: true 1081 + 1082 + /@octokit/plugin-rest-endpoint-methods@5.16.2(@octokit/core@3.6.0): 1083 + resolution: {integrity: sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==} 1084 + peerDependencies: 1085 + '@octokit/core': '>=3' 1086 + dependencies: 1087 + '@octokit/core': 3.6.0 1088 + '@octokit/types': 6.41.0 1089 + deprecation: 2.3.1 1090 + dev: true 1091 + 1092 + /@octokit/request-error@2.1.0: 1093 + resolution: {integrity: sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==} 1094 + dependencies: 1095 + '@octokit/types': 6.41.0 1096 + deprecation: 2.3.1 1097 + once: 1.4.0 1098 + dev: true 1099 + 1100 + /@octokit/request@5.6.3: 1101 + resolution: {integrity: sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==} 1102 + dependencies: 1103 + '@octokit/endpoint': 6.0.12 1104 + '@octokit/request-error': 2.1.0 1105 + '@octokit/types': 6.41.0 1106 + is-plain-object: 5.0.0 1107 + node-fetch: 2.7.0 1108 + universal-user-agent: 6.0.1 1109 + transitivePeerDependencies: 1110 + - encoding 1111 + dev: true 1112 + 1113 + /@octokit/types@6.41.0: 1114 + resolution: {integrity: sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==} 1115 + dependencies: 1116 + '@octokit/openapi-types': 12.11.0 1117 + dev: true 1118 + 995 1119 /@pkgjs/parseargs@0.11.0: 996 1120 resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} 997 1121 engines: {node: '>=14'} ··· 1568 1692 resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} 1569 1693 dev: true 1570 1694 1695 + /before-after-hook@2.2.3: 1696 + resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} 1697 + dev: true 1698 + 1571 1699 /better-path-resolve@1.0.0: 1572 1700 resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} 1573 1701 engines: {node: '>=4'} ··· 1934 2062 object-keys: 1.1.1 1935 2063 dev: true 1936 2064 2065 + /deprecation@2.3.1: 2066 + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} 2067 + dev: true 2068 + 1937 2069 /detect-indent@6.1.0: 1938 2070 resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} 1939 2071 engines: {node: '>=8'} ··· 2836 2968 2837 2969 /is-plain-obj@1.1.0: 2838 2970 resolution: {integrity: sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==} 2971 + engines: {node: '>=0.10.0'} 2972 + dev: true 2973 + 2974 + /is-plain-object@5.0.0: 2975 + resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} 2839 2976 engines: {node: '>=0.10.0'} 2840 2977 dev: true 2841 2978 ··· 4361 4498 yargs: 17.7.2 4362 4499 dev: true 4363 4500 4501 + /tunnel@0.0.6: 4502 + resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} 4503 + engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} 4504 + dev: true 4505 + 4364 4506 /type-check@0.4.0: 4365 4507 resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} 4366 4508 engines: {node: '>= 0.8.0'} ··· 4455 4597 which-boxed-primitive: 1.0.2 4456 4598 dev: true 4457 4599 4600 + /undici@5.28.4: 4601 + resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} 4602 + engines: {node: '>=14.0'} 4603 + dependencies: 4604 + '@fastify/busboy': 2.1.1 4605 + dev: true 4606 + 4607 + /universal-user-agent@6.0.1: 4608 + resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==} 4609 + dev: true 4610 + 4458 4611 /universalify@0.1.2: 4459 4612 resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} 4460 4613 engines: {node: '>= 4.0.0'} ··· 4475 4628 resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} 4476 4629 dependencies: 4477 4630 punycode: 2.3.0 4631 + dev: true 4632 + 4633 + /uuid@8.3.2: 4634 + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} 4635 + hasBin: true 4478 4636 dev: true 4479 4637 4480 4638 /v8-to-istanbul@9.2.0: