我想知道哪里可能是這個(gè)代碼中的錯(cuò)誤。
我得到一個(gè)錯(cuò)誤消息
/home/runner/work/_ temp/f 7610 f6f-2495-4196-8736-156 D1 c 0 a 06 ea . sh:第1行:意外標(biāo)記`('附近出現(xiàn)語法錯(cuò)誤 錯(cuò)誤:進(jìn)程完成,退出代碼為2。
當(dāng)有人在我的網(wǎng)站上按下一個(gè)按鈕并連接到sendgrid時(shí),我試圖獲取一封郵件,但仍然出現(xiàn)錯(cuò)誤
name: Email Notification
on:
push:
branches:
- main
jobs:
sendEmail:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Install PowerShell
run: |
sudo apt-get update
sudo apt-get install -y powershell
pwsh --version # Verify the installation
- name: Capture form data
id: capture-form-data
run: |
echo "::set-output name=data::$(echo '{\"name\": \"'${{ env.INPUT_NAME }}'\", \"email\": \"'${{ env.INPUT_EMAIL }}'\", \"message\": \"'${{ env.INPUT_MESSAGE }}'\"}')"
- name: Send email
env:
TO_EMAIL: ${{ secrets.TO_EMAIL }}
FROM_EMAIL: ${{ secrets.FROM_EMAIL }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
run: |
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const formData = JSON.parse(process.env.CAPTURE_FORM_DATA);
const message = {
to: 'spyfilip@gmail.com', // Replace with your email address
from: 'kontaktstranka@gmail.com', // Replace with the sender email address
subject: 'Form Submission',
text: `A form submission was received:\n\nName: ${formData.name}\nEmail: ${formData.email}\nMessage: ${formData.message}`
};
sgMail.send(message)
.then(() => {
console.log('Email sent successfully');
})
.catch((error) => {
console.error('Error sending email:', error);
});
上一篇c 有沒有json