diff --git a/.github/workflows/application-flow.yml b/.github/workflows/application-flow.yml new file mode 100644 index 0000000..558e14c --- /dev/null +++ b/.github/workflows/application-flow.yml @@ -0,0 +1,92 @@ +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); + 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+))`, + 'gi' + ); + const matches = [...prBody.matchAll(regex)]; + + // 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}`); + } + } 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..5613695 --- /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 via link: https://github.com/holdex/trial/issues?q=is%3Aissue%20state%3Aopen%20label%3Atrial-task diff --git a/profile-submission.json b/profile-submission.json index 359efe1..5ca3be7 100644 --- a/profile-submission.json +++ b/profile-submission.json @@ -19,7 +19,7 @@ "github_handle": "samiksha-kushwah", "full_name": "Samiksha Kushwah", "github_trial_issue_link": "https://github.com/holdex/trial/issues/714" - }, + }, { "github_handle": "VasishtGR", "full_name": "Vasisht G R", @@ -296,9 +296,9 @@ "github_trial_issue_link": "https://github.com/holdex/trial/issues/241" }, { - "github_handle": "piyushuiux", - "full_name": "Piyush Raj Singh", - "github_trial_issue_link": "https://github.com/holdex/trial/issues/478" + "github_handle": "piyushuiux", + "full_name": "Piyush Raj Singh", + "github_trial_issue_link": "https://github.com/holdex/trial/issues/478" }, { "github_handle": "ddadekunle", @@ -316,15 +316,15 @@ "github_trial_issue_link": "https://github.com/holdex/trial/issues/306" }, { - "github_handle": "Productguy1", - "full_name": "Daniel Mbazu", - "github_trial_issue_link": "https://github.com/holdex/trial/issues/285" + "github_handle": "Productguy1", + "full_name": "Daniel Mbazu", + "github_trial_issue_link": "https://github.com/holdex/trial/issues/285" }, { "github_handle": "pandablue0809", "full_name": "Riku Kodama", "github_trial_issue_link": "https://github.com/holdex/trial/issues/82" - }, + }, { "github_handle": "dokiugit", "full_name": "Dhokhiy Mustofa Akbar", @@ -356,9 +356,9 @@ "github_trial_issue_link": "https://github.com/holdex/trial/issues/395" }, { - "github_handle": "jingyi2811", - "full_name": "Lee Jing-yi", - "github_trial_issue_link": "https://github.com/holdex/trial/issues/380" + "github_handle": "jingyi2811", + "full_name": "Lee Jing-yi", + "github_trial_issue_link": "https://github.com/holdex/trial/issues/380" }, { "github_handle": "iiihsy", @@ -385,13 +385,13 @@ "full_name": "Filipe Rey Guimaraes dos Santos", "github_trial_issue_link": "https://github.com/holdex/trial/issues/416" }, - { - "github_handle": "mikaelowenn", + { + "github_handle": "mikaelowenn", "full_name": "Mikael Owen", "github_trial_issue_link": "https://github.com/holdex/trial/issues/397" - }, + }, { - "github_handle": "MuhammadZarq13", + "github_handle": "MuhammadZarq13", "full_name": "Muhammad Zarq Khan", "github_trial_issue_link": "https://github.com/holdex/trial/issues/438" }, @@ -484,7 +484,7 @@ "github_handle": "lilithkk", "full_name": "Jing Lin", "github_trial_issue_link": "https://github.com/holdex/trial/issues/579" - }, + }, { "github_handle": "martins87", "full_name": "Daniel Martins", @@ -524,8 +524,8 @@ "github_handle": "jaibhedia", "full_name": "Shantanu Swami", "github_trial_issue_link": "https://github.com/holdex/trial/issues/680" - }, - { + }, + { "github_handle": "roars2121", "full_name": "Ruairidh Orr Ewing", "github_trial_issue_link": "https://github.com/holdex/trial/issues/645" @@ -579,7 +579,7 @@ "github_handle": "ASKLTON", "full_name": "Alston Lantian Xu", "github_trial_issue_link": "https://github.com/holdex/trial/issues/694" - }, + }, { "github_handle": "RaamPujangga", "full_name": "Raam Pujangga Sadewa", @@ -610,7 +610,7 @@ "full_name": "Lkhamsuren Jargalsaikhan", "github_trial_issue_link": "https://github.com/holdex/trial/issues/726" }, - { + { "github_handle": "siddharth-09", "full_name": "Siddharth Panchal", "github_trial_issue_link": "https://github.com/holdex/trial/issues/708" @@ -655,7 +655,7 @@ "full_name": "Andika Leonardo Surya", "github_trial_issue_link": "https://github.com/holdex/trial/issues/235" }, - { + { "github_handle": "Doziiie", "full_name": "Chiedozie Nwaka", "github_trial_issue_link": "https://github.com/holdex/trial/issues/526" @@ -668,7 +668,7 @@ { "github_handle": "Goeter", "full_name": "Jason Vianney", - "github_trial_issue_link": "https://github.com/holdex/trial/issues/795" + "github_trial_issue_link": "https://github.com/holdex/trial/issues/795" }, { "github_handle": "jpdelostrinos", @@ -824,7 +824,7 @@ "github_handle": "HimanshuJain04", "full_name": "Himanshu Jain", "github_trial_issue_link": "https://github.com/holdex/trial/issues/975" - }, + }, { "github_handle": "cryptox427", "full_name": "Sudais Budhathoki", @@ -875,13 +875,13 @@ "full_name": "Nastasha Primera", "github_trial_issue_link": "https://github.com/holdex/trial/issues/1039" }, - { - "github_handle": "Nikhil8400", + { + "github_handle": "Nikhil8400", "full_name": "Nikhil Pandey", "github_trial_issue_link": "https://github.com/holdex/trial/issues/439" }, - { - "github_handle": "zzzLydia", + { + "github_handle": "zzzLydia", "full_name": "Zezheng Zhang", "github_trial_issue_link": "https://github.com/holdex/trial/issues/1044" }, @@ -889,8 +889,8 @@ "github_handle": "Nightowl1905", "full_name": "Dom Lai", "github_trial_issue_link": "https://github.com/holdex/trial/issues/1038" - }, - { + }, + { "github_handle": "arishtj", "full_name": "Arisht Jain", "github_trial_issue_link": "https://github.com/holdex/trial/issues/675" @@ -900,10 +900,15 @@ "full_name": "Ananta Kusuma P", "github_trial_issue_link": "https://github.com/holdex/trial/issues/1095" }, - { - "github_handle": "forvy", - "full_name": "Theodore Widjaja", - "github_trial_issue_link": "https://github.com/holdex/trial/issues/1090" - }, + { + "github_handle": "forvy", + "full_name": "Theodore Widjaja", + "github_trial_issue_link": "https://github.com/holdex/trial/issues/1090" + }, + { + "github_handle": "Test9", + "full_name": "Test9", + "github_trial_issue_link": "https://github.com/holdex/trial/issues/1090" + } ] -} \ No newline at end of file +}