From 0d6201277a31a8a9b74fdaf896b8b4217a58e1f3 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Wed, 4 Mar 2026 21:15:36 +0700 Subject: [PATCH 01/11] feat: add github workflow for job applications --- .github/workflows/application-flow.yml | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/application-flow.yml diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml new file mode 100644 index 0000000..af19d2b --- /dev/null +++ b/.github/workflows/application-flow.yml @@ -0,0 +1,68 @@ +name: Application Flow + +on: + issues: + types: [opened] + pull_request: + types: [closed] + +jobs: + ask-for-pr: + if: github.event_name == 'issues' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Comment with PR instructions + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue; + const candidate = issue.user.login; + const commentBody = `Hi @${candidate} — thanks for applying! Please add your profile by opening a pull request that adds a JSON file with your profile under profile-submission.json. In your PR description include "resolves: #${issue.number}" or "closes: #${issue.number}" so we can link it to this application. Once your PR is merged we'll reopen this issue and ask you to proceed with the trial task.`; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + body: commentBody + }); + try { + await github.rest.issues.addLabels({ ...context.repo, issue_number: issue.number, labels: ['job-application'] }); + } catch (e) { + console.log('Could not add label:', e.message); + } + + reopen-issue: + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Reopen linked issues and ask to proceed + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const prBody = context.payload.pull_request.body || ''; + const regex = /(?:resolves|closes):?\s*(?:#|https:\/\/github\.com\/[^\/]+\/[^\/]+\/issues\/)(\d+)/gi;; + const matches = [...prBody.matchAll(regex)]; + + // Extract the numbers and remove duplicates + const issueNumbers = [...new Set(matches.map(m => parseInt(m[1], 10)))]; + + for (const issue_number of issueNumbers) { + try { + // The actual command to reopen + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + state: 'open' + }); + } catch (error) { + console.log(`Could not reopen issue #${issue_number}: ${error.message}`); + } + } From d367b00deba7d4bb857b4b5fee81cc0384275153 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Thu, 5 Mar 2026 19:25:10 +0700 Subject: [PATCH 02/11] fix: fix based on coderabbit suggestions --- .github/workflows/application-flow.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index af19d2b..6c12ddf 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -47,11 +47,14 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const prBody = context.payload.pull_request.body || ''; - const regex = /(?:resolves|closes):?\s*(?:#|https:\/\/github\.com\/[^\/]+\/[^\/]+\/issues\/)(\d+)/gi;; + const regex = new RegExp( + `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, + 'gi' + ); const matches = [...prBody.matchAll(regex)]; // Extract the numbers and remove duplicates - const issueNumbers = [...new Set(matches.map(m => parseInt(m[1], 10)))]; + const issueNumbers = [...new Set(matches.map(m => parseInt(m[1] || m[2], 10)))]; for (const issue_number of issueNumbers) { try { @@ -62,6 +65,13 @@ jobs: issue_number: issue_number, state: 'open' }); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: `Hi @${context.payload.pull_request.user.login} — your profile PR was merged. Please proceed with the trial task.` + }); } catch (error) { console.log(`Could not reopen issue #${issue_number}: ${error.message}`); } From e91ee89a984e7082a9f89726ac616a17d286a1ab Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Thu, 5 Mar 2026 19:37:38 +0700 Subject: [PATCH 03/11] fix: fix undefine owner and repo --- .github/workflows/application-flow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 6c12ddf..4aae1f2 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -46,6 +46,8 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const owner = context.repo.owner.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const repo = context.repo.repo.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const prBody = context.payload.pull_request.body || ''; const regex = new RegExp( `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, From e9856e7411f1df48acdcdc80ee8b5c28a276c0c4 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Fri, 6 Mar 2026 19:56:34 +0700 Subject: [PATCH 04/11] fix: use md file to show comment github bot --- .github/workflows/application-flow.yml | 18 ++++++++++++++++-- .../workflows/application-follow-up-body.md | 1 + .github/workflows/application-merged-body.md | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/application-follow-up-body.md create mode 100644 .github/workflows/application-merged-body.md diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 4aae1f2..8cb4924 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -19,9 +19,15 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const fs = require('fs'); + const path = require('path'); + const issue = context.payload.issue; + const candidate = issue.user.login; + const workspace = process.env.GITHUB_WORKSPACE; + const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-follow-up-body.md'), 'utf8') + .replace('${candidate}', candidate); const issue = context.payload.issue; const candidate = issue.user.login; - const commentBody = `Hi @${candidate} — thanks for applying! Please add your profile by opening a pull request that adds a JSON file with your profile under profile-submission.json. In your PR description include "resolves: #${issue.number}" or "closes: #${issue.number}" so we can link it to this application. Once your PR is merged we'll reopen this issue and ask you to proceed with the trial task.`; await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, @@ -46,6 +52,8 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + const fs = require('fs'); + const path = require('path'); const owner = context.repo.owner.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const repo = context.repo.repo.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const prBody = context.payload.pull_request.body || ''; @@ -58,6 +66,12 @@ jobs: // Extract the numbers and remove duplicates const issueNumbers = [...new Set(matches.map(m => parseInt(m[1] || m[2], 10)))]; + // use md file + const workspace = process.env.GITHUB_WORKSPACE; + const user = context.payload.pull_request.user.login + const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-merged-body.md'), 'utf8') + .replace('${user}', user); + for (const issue_number of issueNumbers) { try { // The actual command to reopen @@ -72,7 +86,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: `Hi @${context.payload.pull_request.user.login} — your profile PR was merged. Please proceed with the trial task.` + body: commentBody }); } catch (error) { console.log(`Could not reopen issue #${issue_number}: ${error.message}`); diff --git a/.github/workflows/application-follow-up-body.md b/.github/workflows/application-follow-up-body.md new file mode 100644 index 0000000..411ac50 --- /dev/null +++ b/.github/workflows/application-follow-up-body.md @@ -0,0 +1 @@ +Hi @${candidate} — thanks for applying! Please add your profile by opening a pull request that adds a JSON file with your profile under profile-submission.json. In your PR description include "resolves: #${issue.number}" or "closes: #${issue.number}" so we can link it to this application. Once your PR is merged we'll reopen this issue and ask you to proceed with the trial task. diff --git a/.github/workflows/application-merged-body.md b/.github/workflows/application-merged-body.md new file mode 100644 index 0000000..521b2f4 --- /dev/null +++ b/.github/workflows/application-merged-body.md @@ -0,0 +1 @@ +Hi @${user} — your profile PR was merged. Please proceed with the trial task. From 9f8c933e3d75484791a39c50615358c88b7d942a Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Fri, 6 Mar 2026 20:02:09 +0700 Subject: [PATCH 05/11] fix: fix broken application-flow.yml and add link --- .github/workflows/application-flow.yml | 1 - .github/workflows/application-merged-body.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 8cb4924..43c8ed6 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -26,7 +26,6 @@ jobs: const workspace = process.env.GITHUB_WORKSPACE; const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-follow-up-body.md'), 'utf8') .replace('${candidate}', candidate); - const issue = context.payload.issue; const candidate = issue.user.login; await github.rest.issues.createComment({ owner: context.repo.owner, diff --git a/.github/workflows/application-merged-body.md b/.github/workflows/application-merged-body.md index 521b2f4..5613695 100644 --- a/.github/workflows/application-merged-body.md +++ b/.github/workflows/application-merged-body.md @@ -1 +1 @@ -Hi @${user} — your profile PR was merged. Please proceed with the trial task. +Hi @${user} — your profile PR was merged. Please proceed with the trial task via link: https://github.com/holdex/trial/issues?q=is%3Aissue%20state%3Aopen%20label%3Atrial-task From c454c04ebc945488fd885d09a538a1c27fa56ed0 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Fri, 6 Mar 2026 20:05:25 +0700 Subject: [PATCH 06/11] fix: fix double variable candidate --- .github/workflows/application-flow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 43c8ed6..558e14c 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -26,7 +26,6 @@ jobs: const workspace = process.env.GITHUB_WORKSPACE; const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-follow-up-body.md'), 'utf8') .replace('${candidate}', candidate); - const candidate = issue.user.login; await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, From bc2908d080c1d9a5df414bcd8f7491de3b44ce46 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Fri, 6 Mar 2026 20:26:03 +0700 Subject: [PATCH 07/11] fix: fix issue number --- .github/workflows/application-flow.yml | 3 ++- .github/workflows/application-follow-up-body.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 558e14c..bc1b9bc 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -25,7 +25,8 @@ jobs: const candidate = issue.user.login; const workspace = process.env.GITHUB_WORKSPACE; const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-follow-up-body.md'), 'utf8') - .replace('${candidate}', candidate); + .replace('${candidate}', candidate) + .replace('${issue_number}', issue.number); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/workflows/application-follow-up-body.md b/.github/workflows/application-follow-up-body.md index 411ac50..0841acb 100644 --- a/.github/workflows/application-follow-up-body.md +++ b/.github/workflows/application-follow-up-body.md @@ -1 +1 @@ -Hi @${candidate} — thanks for applying! Please add your profile by opening a pull request that adds a JSON file with your profile under profile-submission.json. In your PR description include "resolves: #${issue.number}" or "closes: #${issue.number}" so we can link it to this application. Once your PR is merged we'll reopen this issue and ask you to proceed with the trial task. +Hi @${candidate} — thanks for applying! Please add your profile by opening a pull request that adds a JSON file with your profile under profile-submission.json. In your PR description include "resolves: #${issue_number}" or "closes: #${issue_number}" so we can link it to this application. Once your PR is merged we'll reopen this issue and ask you to proceed with the trial task. From b59c436d2461c263d02ef91a89350a8f3849f4bf Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Fri, 6 Mar 2026 20:31:52 +0700 Subject: [PATCH 08/11] fix: fix issue number by using replaceAll --- .github/workflows/application-flow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index bc1b9bc..e60205f 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -26,7 +26,7 @@ jobs: const workspace = process.env.GITHUB_WORKSPACE; const commentBody = fs.readFileSync(path.join(workspace, '.github/workflows/application-follow-up-body.md'), 'utf8') .replace('${candidate}', candidate) - .replace('${issue_number}', issue.number); + .replaceAll('${issue_number}', issue.number); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, From 456859146640458b215c388e35d19319557e449c Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Thu, 12 Mar 2026 20:04:33 +0700 Subject: [PATCH 09/11] fix: use mi instead gi for regex --- .github/workflows/application-flow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index e60205f..fc8dcf8 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -58,7 +58,7 @@ jobs: const prBody = context.payload.pull_request.body || ''; const regex = new RegExp( `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, - 'gi' + 'mi' ); const matches = [...prBody.matchAll(regex)]; From bffbf2ac34d40e3ce4101abc36686061219d835e Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Thu, 12 Mar 2026 20:18:58 +0700 Subject: [PATCH 10/11] fix: fix error because using mi --- .github/workflows/application-flow.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index fc8dcf8..35eade6 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -60,7 +60,13 @@ jobs: `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, 'mi' ); - const matches = [...prBody.matchAll(regex)]; + const matches = []; + let match; + + while ((match = regex.exec(prBody)) !== null) { + matches.push(match); + regex.lastIndex = 0; // reset index so it does not continue from previous position + } // Extract the numbers and remove duplicates const issueNumbers = [...new Set(matches.map(m => parseInt(m[1] || m[2], 10)))]; From a66bf862c1955b06b4b8436e78c969c03c1b4223 Mon Sep 17 00:00:00 2001 From: Ananta98 Date: Thu, 12 Mar 2026 20:28:04 +0700 Subject: [PATCH 11/11] fix: fix error recursive --- .github/workflows/application-flow.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml index 35eade6..bfaa1ac 100644 --- a/.github/workflows/application-flow.yml +++ b/.github/workflows/application-flow.yml @@ -60,12 +60,18 @@ jobs: `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, 'mi' ); + + let remaining = prBody; const matches = []; - let match; - while ((match = regex.exec(prBody)) !== null) { + while (true) { + const match = regex.exec(remaining); + if (!match) break; + matches.push(match); - regex.lastIndex = 0; // reset index so it does not continue from previous position + + // move forward in the string manually + remaining = remaining.slice(match.index + match[0].length); } // Extract the numbers and remove duplicates