diff --git a/.github/workflows/buildAndSendOSignatures.yml b/.github/workflows/buildAndSendOSignatures.yml new file mode 100644 index 0000000..5edfcc1 --- /dev/null +++ b/.github/workflows/buildAndSendOSignatures.yml @@ -0,0 +1,55 @@ +name: buildAndSendJSignatures + +on: + push: + branches: + - 'master' + paths: + - 'data/X.json' + - 'templates/template.html' + +env: + O_NAME: ${{ secrets._NAME }} + O_PHONE: ${{ secrets.O_PHONE }} + O_IPHONE: ${{ secrets.O_IPHONE }} + O_EMAIL: ${{ secrets.O_EMAIL }} + GH_ACTIONS_ENV: true + +jobs: + build_and_send_signatures: + runs-on: ubuntu-latest + steps: + - + name: Checkout code + uses: actions/checkout@v3 + - + name: Substitute marks (implicit parameters in env) + run: | + chmod u+x src/substituteMarks.sh + ./src/substituteMarks.sh + - + name: Set up nodeJS + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - + name: Render signatures + run: | + npm install + node ./src/renderSignatures.js + - + name: Send emails + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.gmail.com + server_port: 465 + secure: true + username: ${{secrets.EMAIL_USERNAME}} + password: ${{secrets.EMAIL_PASSWORD}} + subject: Actualització de firmes electròniques + to: ${{secrets.O_EMAIL}}, ${{secrets.EMAIL_USERNAME}} + from: ${{secrets.EMAIL_USERNAME}} + body: Aquest missatge ha estat auto-generat. + ignore_cert: true + attachments: ./out/*.html + priority: low \ No newline at end of file diff --git a/.github/workflows/buildAndSendXSignatures.yml b/.github/workflows/buildAndSendXSignatures.yml new file mode 100644 index 0000000..6f20e60 --- /dev/null +++ b/.github/workflows/buildAndSendXSignatures.yml @@ -0,0 +1,55 @@ +name: buildAndSendJSignatures + +on: + push: + branches: + - 'master' + paths: + - 'data/X.json' + - 'templates/template.html' + +env: + X_NAME: ${{ secrets._NAME }} + X_PHONE: ${{ secrets.X_PHONE }} + X_IPHONE: ${{ secrets.X_IPHONE }} + X_EMAIL: ${{ secrets.X_EMAIL }} + GH_ACTIONS_ENV: true + +jobs: + build_and_send_signatures: + runs-on: ubuntu-latest + steps: + - + name: Checkout code + uses: actions/checkout@v3 + - + name: Substitute marks (implicit parameters in env) + run: | + chmod u+x src/substituteMarks.sh + ./src/substituteMarks.sh + - + name: Set up nodeJS + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - + name: Render signatures + run: | + npm install + node ./src/renderSignatures.js + - + name: Send emails + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.gmail.com + server_port: 465 + secure: true + username: ${{secrets.EMAIL_USERNAME}} + password: ${{secrets.EMAIL_PASSWORD}} + subject: Actualització de firmes electròniques + to: ${{secrets.X_EMAIL}}, ${{secrets.EMAIL_USERNAME}} + from: ${{secrets.EMAIL_USERNAME}} + body: Aquest missatge ha estat auto-generat. + ignore_cert: true + attachments: ./out/*.html + priority: low \ No newline at end of file diff --git a/README.md b/README.md index 4b2daf5..ff2284d 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ If there is the need to add a new signature you need a workflow that manages tha and the phone with international prefix (without spaces to generate a proper `mailto:` link), where N is the initial or another string that identifies the person but without revealing any of its personal data. -- Create the file N.json in the `data` folder. N needs to be the same. +- Create the file `N.json` in the `data` folder. N needs to be the same. - Create the workflow `sendSignatureToN.yml` that is configured to send the signature to its owner and is triggered only when the signature is modified. - Add the files, commit and push to GitHub to trigger the workflow. @@ -95,7 +95,7 @@ whitespace or a line break. Since the workflow is only triggered when the signature is updated, you can add a meaningless change in the data file of the signature such as adding a -whitespace or a line break. +whitespace or a line break to trigger the workflow and receive the signatures in your email. ## Roadmap This project is completely functional! But there is still some space for improvements... diff --git a/data/O.json b/data/O.json new file mode 100644 index 0000000..9b097d1 --- /dev/null +++ b/data/O.json @@ -0,0 +1,6 @@ +{ + "name": "{{O_NAME}}", + "phone": "{{O_PHONE}}", + "internationalPhone": "{{O_IPHONE}}", + "email": "{{O_EMAIL}}" +} diff --git a/data/X.json b/data/X.json new file mode 100644 index 0000000..a285742 --- /dev/null +++ b/data/X.json @@ -0,0 +1,6 @@ +{ + "name": "{{X_NAME}}", + "phone": "{{X_PHONE}}", + "internationalPhone": "{{X_IPHONE}}", + "email": "{{X_EMAIL}}" +}