forked from Equipaments-Hosteleria-Salou/email-signatures
-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (132 loc) · 5.66 KB
/
buildAndSendSignatures.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: buildAndSendSignatures
on:
push:
branches:
- 'master'
paths:
- 'data/**.json'
- 'templates/template.html'
env:
GH_ACTIONS_ENV: true
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
VICEPRESIDENT_LINKEDIN: ${{ secrets.VICEPRESIDENT_LINKEDIN }}
VICEPRESIDENT_POSITION: ${{ secrets.VICEPRESIDENT_POSITION }}
VICEPRESIDENT_EMAIL: ${{ secrets.VICEPRESIDENT_EMAIL }}
VICEPRESIDENT_NAME: ${{ secrets.VICEPRESIDENT_NAME }}
COMMUNICATION_POSITION: ${{ secrets.COMMUNICATION_POSITION }}
COMMUNICATION_LINKEDIN: ${{ secrets.COMMUNICATION_LINKEDIN }}
COMMUNICATION_EMAIL: ${{ secrets.COMMUNICATION_EMAIL }}
COMMUNICATION_NAME: ${{ secrets.COMMUNICATION_NAME }}
TREASURER_POSITION: ${{ secrets.TREASURER_POSITION }}
TREASURER_LINKEDIN: ${{ secrets.TREASURER_LINKEDIN }}
TREASURER_EMAIL: ${{ secrets.TREASURER_EMAIL }}
TREASURER_NAME: ${{ secrets.TREASURER_NAME }}
SECRETARY_LINKEDIN: ${{ secrets.SECRETARY_LINKEDIN }}
SECRETARY_POSITION: ${{ secrets.SECRETARY_POSITION }}
SECRETARY_EMAIL: ${{ secrets.SECRETARY_EMAIL }}
SECRETARY_NAME: ${{ secrets.SECRETARY_NAME }}
PRESIDENT_LINKEDIN: ${{ secrets.PRESIDENT_LINKEDIN }}
PRESIDENT_POSITION: ${{ secrets.PRESIDENT_POSITION }}
PRESIDENT_EMAIL: ${{ secrets.PRESIDENT_EMAIL }}
PRESIDENT_NAME: ${{ secrets.PRESIDENT_NAME }}
ALEIXMT_LINKEDIN: ${{ secrets.ALEIXMT_LINKEDIN }}
ALEIXMT_POSITION: ${{ secrets.ALEIXMT_POSITION }}
ALEIXMT_EMAIL: ${{ secrets.ALEIXMT_EMAIL }}
ALEIXMT_NAME: ${{ secrets.ALEIXMT_NAME }}
INFORMATICS_LINKEDIN: ${{ secrets.INFORMATICS_LINKEDIN }}
INFORMATICS_POSITION: ${{ secrets.INFORMATICS_POSITION }}
INFORMATICS_EMAIL: ${{ secrets.INFORMATICS_EMAIL }}
INFORMATICS_NAME: ${{ secrets.INFORMATICS_NAME }}
ACTIVITIES_NAME: ${{ secrets.ACTIVITIES_NAME }}
ACTIVITIES_EMAIL: ${{ secrets.ACTIVITIES_EMAIL }}
ACTIVITIES_POSITION: ${{ secrets.ACTIVITIES_POSITION }}
ACTIVITIES_LINKEDIN: ${{ secrets.ACTIVITIES_LINKEDIN }}
ADVISER_NAME: ${{ secrets.ADVISER_NAME }}
ADVISER_EMAIL: ${{ secrets.ADVISER_EMAIL }}
ADVISER_POSITION: ${{ secrets.ADVISER_POSITION }}
ADVISER_LINKEDIN: ${{ secrets.ADVISER_LINKEDIN }}
UNIVERSITIES_NAME: ${{ secrets.UNIVERSITIES_NAME }}
UNIVERSITIES_EMAIL: ${{ secrets.UNIVERSITIES_EMAIL }}
UNIVERSITIES_POSITION: ${{ secrets.UNIVERSITIES_POSITION }}
UNIVERSITIES_LINKEDIN: ${{ secrets.UNIVERSITIES_LINKEDIN }}
JORNADES_NAME: ${{ secrets.JORNADES_NAME }}
JORNADES_EMAIL: ${{ secrets.JORNADES_EMAIL }}
JORNADES_POSITION: ${{ secrets.JORNADES_POSITION }}
JORNADES_LINKEDIN: ${{ secrets.JORNADES_LINKEDIN }}
DELEGATIONS_NAME: ${{ secrets.DELEGATIONS_NAME }}
DELEGATIONS_EMAIL: ${{ secrets.DELEGATIONS_EMAIL }}
DELEGATIONS_POSITION: ${{ secrets.DELEGATIONS_POSITION }}
DELEGATIONS_LINKEDIN: ${{ secrets.DELEGATIONS_LINKEDIN }}
UDL_NAME: ${{ secrets.UDL_NAME }}
UDL_EMAIL: ${{ secrets.UDL_EMAIL }}
UDL_POSITION: ${{ secrets.UDL_POSITION }}
UDL_LINKEDIN: ${{ secrets.UDL_LINKEDIN }}
jobs:
build_and_send_signatures:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
# https://stackoverflow.com/questions/74265821/get-modified-files-in-github-actions
- name: Get changed files
id: changed-files
run: |
# Get modified files as input
input_text=""
if ${{ github.event_name == 'pull_request' }}; then
input_text="$(git diff --name-only -r HEAD^1 HEAD | xargs)"
else
input_text="$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)"
fi
# Detect if the template has been modified
template_modified=false
for file in ${input_text}; do
if [ "templates/template.html" = "${file}" ]; then
template_modified=true
fi
done
# Select the signatures that are going to be built
signatures_to_build=""
if [ "${template_modified}" = "false" ]; then
for file in ${input_text}; do
echo value $file
if echo "${file}" | grep -q "/"; then
if [ "$(echo "${file}" | cut -f1 -d "/")" = "data" ]; then
if echo "${file}" | grep -q "."; then
signatures_to_build="$(echo "${file}" | cut -d "/" -f2 | cut -d "." -f1) ${signatures_to_build}"
fi
fi
fi
done
else # template_modified = true
for file in data/*.json; do
signatures_to_build="$(echo "${file}" | cut -d "/" -f2 | cut -d "." -f1) ${signatures_to_build}"
done
fi
echo "signatures_to_build=${signatures_to_build}"
echo "signatures_to_build=${signatures_to_build}" >> $GITHUB_OUTPUT
- name: List changed files
run: |
echo "Signatures to build:"
for file in ${{ steps.changed-files.outputs.signatures_to_build }}; do
echo "$file"
done
- name: Substitute marks (implicit parameters in env)
run: |
chmod u+x src/substituteMarks.sh
./src/substituteMarks.sh ${{ steps.changed-files.outputs.signatures_to_build }}
- 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
id: send-emails
run: |
chmod u+x src/sendEmails.sh
./src/sendEmails.sh ${{ steps.changed-files.outputs.signatures_to_build }}