Browse Source

Update Workflow

yaavi 1 year ago
parent
commit
afd3ceb0bf
2 changed files with 7 additions and 8 deletions
  1. 4 6
      .github/workflows/send-email.yml
  2. 3 2
      scripts/fetch.ts

+ 4 - 6
.github/workflows/send-email.yml

@@ -29,9 +29,9 @@ jobs:
     - name: Read holidays file
       id: read-holidays
       run: |
-        echo "HOLIDAYS_CONTENT=$(cat holidays.txt)" >> $GITHUB_ENV
+        echo "HOLIDAYS_CONTENT=$(cat holidays.html)" >> $GITHUB_ENV
       env:
-        HOLIDAYS_CONTENT: $(cat holidays.txt)
+        HOLIDAYS_CONTENT: $(cat holidays.html)
 
     - name: Send notification if holidays has value
       if: ${{ steps.run-script.outputs.holidays != '' }}
@@ -43,7 +43,5 @@ jobs:
         password: ${{ secrets.EMAIL_PASSWORD }}
         subject: "2024 Holidays Result has value - GitHub Actions"
         to: hi@yaavi.me
-        from: Github
-        body: |
-          Result has value: 
-          ${{ env.HOLIDAYS_CONTENT }}
+        from: Holidays Update
+        html_body: ${{ env.HOLIDAYS_CONTENT }}

+ 3 - 2
scripts/fetch.ts

@@ -101,12 +101,13 @@ const main = async () => {
   const year = args.year;
   console.log(`Fetching holiday for ${year}...`);
 
-  const result = await fetchHoliday(year);
+  let result = await fetchHoliday(year);
 
   if (result && result.length > 0) {
     console.log(result)
+    result = result.split('\n').map(line => `<p>${line}</p>`).join('')
     const outputPath = process.env.GITHUB_OUTPUT;
-    const holidaysFile = path.join(process.cwd(), 'holidays.txt');
+    const holidaysFile = path.join(process.cwd(), 'holidays.html');
     fs.writeFileSync(holidaysFile, result);
     if (outputPath) {
       fs.appendFileSync(outputPath, `holidays=${holidaysFile}\n`);