|
| 1 | +name: Create Outline for Cover Letter (Gemini) |
| 2 | +description: Use Google Gemini to create an outline for a cover letter based on a resume and job description. |
| 3 | + |
| 4 | +inputs: |
| 5 | + GOOGLE_API_KEY: |
| 6 | + description: Google API Key For Gemini |
| 7 | + required: true |
| 8 | + GEMINI_MODEL: |
| 9 | + description: Gemini Model |
| 10 | + required: true |
| 11 | + default: gemini-2.0-flash |
| 12 | + RESUME_TEXT: |
| 13 | + description: Resume Text |
| 14 | + required: true |
| 15 | + RESUME_MIME_TYPE: |
| 16 | + description: Resume Mime Type |
| 17 | + required: true |
| 18 | + default: text/html |
| 19 | + JOB_DESCRIPTION: |
| 20 | + description: Job Description |
| 21 | + required: true |
| 22 | + JOB_DESCRIPTION_MIME_TYPE: |
| 23 | + description: Job Description Mime Type |
| 24 | + required: true |
| 25 | + default: text/plain |
| 26 | + COMPANY_CAREER_INFO: |
| 27 | + description: Text found on the company's websites that describes the company culture, values, mission, and any other details provided on the Company's website which they present to prospective candidates |
| 28 | + required: true |
| 29 | + default: text/plain |
| 30 | + COMPANY_CAREER_INFO_MIME_TYPE: |
| 31 | + description: Company career info mime type |
| 32 | + required: true |
| 33 | + default: text/plain |
| 34 | + PERSONA: |
| 35 | + description: The persona to use for the system instruction. This is used to set the tone and style of the response. |
| 36 | + required: true |
| 37 | + default: Act as an expert technical recruiter with a previous career in software engineering who can crtically compare resumes to job descriptions to help a candidate write a cover letter. |
| 38 | + |
| 39 | +outputs: |
| 40 | + RAW: |
| 41 | + description: The raw response generated by Gemini. |
| 42 | + value: ${{ steps.gemini-check.outputs.RAW }} |
| 43 | + RESPONSE_TEXT: |
| 44 | + description: 'The text response generated by Gemini which was instructed to output JSON with they keys: score, explanation, deficiencies, strengths, and recommendations.' |
| 45 | + value: ${{ steps.gemini-check.outputs.RESPONSE_TEXT }} |
| 46 | + |
| 47 | +runs: |
| 48 | + using: composite |
| 49 | + steps: |
| 50 | + - name: Query Candidate Qualification |
| 51 | + id: gemini-check |
| 52 | + uses: actions/github-script@v7 |
| 53 | + env: |
| 54 | + GOOGLE_API_KEY: ${{ inputs.GOOGLE_API_KEY }} |
| 55 | + GEMINI_MODEL: ${{ inputs.GEMINI_MODEL }} |
| 56 | + RESUME_MIME_TYPE: ${{ inputs.RESUME_MIME_TYPE }} |
| 57 | + RESUME_TEXT: ${{ inputs.RESUME_TEXT }} |
| 58 | + JOB_DESCRIPTION_MIME_TYPE: ${{ inputs.JOB_DESCRIPTION_MIME_TYPE }} |
| 59 | + JOB_DESCRIPTION: ${{ inputs.JOB_DESCRIPTION }} |
| 60 | + COMPANY_CAREER_INFO_MIME_TYPE: ${{ inputs.COMPANY_CAREER_INFO_MIME_TYPE }} |
| 61 | + COMPANY_CAREER_INFO: ${{ inputs.COMPANY_CAREER_INFO }} |
| 62 | + PERSONA: ${{ inputs.PERSONA }} |
| 63 | + with: |
| 64 | + script: | |
| 65 | + const payload = { |
| 66 | + system_instruction: { |
| 67 | + parts: { |
| 68 | + text: process.env.PERSONA |
| 69 | + } |
| 70 | + }, |
| 71 | + contents: [ |
| 72 | + { |
| 73 | + parts: [ |
| 74 | + { |
| 75 | + text: `Compare the resume, the job description, and the company career page information with the goal of helping the candidate write a cover letter by suggesting an outline for the letter. Provide a JSON formatted response containing the following key/value pairs: |
| 76 | + - introduction_help: a short paragraph to help the candidate write an introduction to the cover letter that includes some suggested phrasing that will help the candidate get started with a friendly and professional tone. |
| 77 | + - outline: a list of brief descriptions of what to include in the cover letter. Be sure to incorporate the company career information provided in the input. |
| 78 | + - conclusion_help: a short paragraph to help the candidate write a conclusion to the cover letter that includes some suggested phrasing that will help the candidate finish the letter with a friendly and professional tone. |
| 79 | + - additional_help: a short paragraph to help the candidate write a cover letter that includes some suggested phrasing that will help the candidate finish the letter with a friendly and professional tone. |
| 80 | +
|
| 81 | + The JSON should be valid, parsable, use 2 spaces for indentation, and contain no additional formatting or comments.` |
| 82 | + }, |
| 83 | + { |
| 84 | + inline_data: { |
| 85 | + mime_type: process.env.RESUME_MIME_TYPE, |
| 86 | + data: Buffer.from(process.env.RESUME_TEXT).toString('base64') |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + inline_data: { |
| 91 | + mime_type: process.env.JOB_DESCRIPTION_MIME_TYPE, |
| 92 | + data: Buffer.from(process.env.JOB_DESCRIPTION).toString('base64') |
| 93 | + } |
| 94 | + }, |
| 95 | + { |
| 96 | + inline_data: { |
| 97 | + mime_type: process.env.COMPANY_CAREER_INFO_MIME_TYPE, |
| 98 | + data: Buffer.from(process.env.COMPANY_CAREER_INFO).toString('base64') |
| 99 | + } |
| 100 | + } |
| 101 | +
|
| 102 | + ] |
| 103 | + } |
| 104 | + ] |
| 105 | + }; |
| 106 | +
|
| 107 | + const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${process.env.GEMINI_MODEL}:generateContent?key=${process.env.GOOGLE_API_KEY}`, { |
| 108 | + method: 'POST', |
| 109 | + headers: { |
| 110 | + 'Content-Type': 'application/json' |
| 111 | + }, |
| 112 | + body: JSON.stringify(payload) |
| 113 | + }); |
| 114 | +
|
| 115 | + const data = await response.json(); |
| 116 | + console.log('Gemini response:', JSON.stringify(data, null, 2)); |
| 117 | + let resultText = data.candidates[0].content.parts[0].text; |
| 118 | + resultText = resultText.replace(/```json|```/g, '').trim(); |
| 119 | +
|
| 120 | + core.setOutput('RAW', JSON.stringify(data, null, 2)); |
| 121 | + core.setOutput('RESPONSE_TEXT', resultText); |
0 commit comments