-
Notifications
You must be signed in to change notification settings - Fork 233
feat(workflow): receive invitation for a trial task #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d62012
feat: add github workflow for job applications
Ananta98 d367b00
fix: fix based on coderabbit suggestions
Ananta98 e91ee89
fix: fix undefine owner and repo
Ananta98 e9856e7
fix: use md file to show comment github bot
Ananta98 9f8c933
fix: fix broken application-flow.yml and add link
Ananta98 c454c04
fix: fix double variable candidate
Ananta98 bc2908d
fix: fix issue number
Ananta98 b59c436
fix: fix issue number by using replaceAll
Ananta98 4568591
fix: use mi instead gi for regex
Ananta98 bffbf2a
fix: fix error because using mi
Ananta98 a66bf86
fix: fix error recursive
Ananta98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| 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 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) | ||
| .replaceAll('${issue_number}', issue.number); | ||
| 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 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 || ''; | ||
| const regex = new RegExp( | ||
| `(?:resolves|closes):?\\s*(?:#(\\d+)|https:\\/\\/github\\.com\\/${owner}\\/${repo}\\/issues\\/(\\d+))`, | ||
| 'mi' | ||
| ); | ||
|
|
||
| let remaining = prBody; | ||
| const matches = []; | ||
|
|
||
| while (true) { | ||
| const match = regex.exec(remaining); | ||
| if (!match) break; | ||
|
|
||
| matches.push(match); | ||
|
|
||
| // move forward in the string manually | ||
| remaining = remaining.slice(match.index + match[0].length); | ||
| } | ||
|
|
||
| // 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 | ||
| await github.rest.issues.update({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| state: 'open' | ||
| }); | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| body: commentBody | ||
| }); | ||
| } catch (error) { | ||
| console.log(`Could not reopen issue #${issue_number}: ${error.message}`); | ||
| } | ||
Ananta98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.