-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.91 KB
/
csvupdate.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
name: Update license file
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
check-csv:
runs-on: ubuntu-latest
steps:
# Checkout del repository
- name: Checkout repository
uses: actions/[email protected]
# Configurazione di Git per gestire CRLF e LF
- name: Setup git to handle CRLF/LF differences
run: git config --global core.autocrlf input
# Download del nuovo file CSV
- name: Download new CSV file
run: |
curl -o "Product names and service plan identifiers for licensing.csv" "https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv"
# Confronto tra i file CSV
- name: Compare CSV files ignoring whitespace and line endings
id: compare_files
run: |
if diff --strip-trailing-cr --ignore-all-space "Product names and service plan identifiers for licensing.csv" "JSON/Product names and service plan identifiers for licensing.csv"; then
echo "Files are identical. No update needed."
echo "files_identical=true" >> $GITHUB_ENV
else
echo "Files are different. Update required."
echo "files_identical=false" >> $GITHUB_ENV
fi
# Sostituzione del file CSV se necessario
- name: Replace CSV file if necessary
if: env.files_identical == 'false'
run: |
mv "Product names and service plan identifiers for licensing.csv" "JSON/Product names and service plan identifiers for licensing.csv"
# Installa csvtojson per convertire il CSV in JSON
- name: Install csvtojson
if: env.files_identical == 'false'
run: npm install -g csvtojson
# Converti il CSV in JSON
- name: Convert CSV to JSON
if: env.files_identical == 'false'
run: |
csvtojson "JSON/Product names and service plan identifiers for licensing.csv" > "JSON/M365_licenses.json"
# Debug: Controlla se Git rileva le modifiche
- name: Check for changes
run: |
git status
git diff "JSON/Product names and service plan identifiers for licensing.csv"
git diff "JSON/M365_licenses.json"
# Commit e push delle modifiche, se necessarie
- name: Commit and push changes
if: env.files_identical == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add --renormalize "JSON/Product names and service plan identifiers for licensing.csv" --force
git add --renormalize "JSON/M365_licenses.json" --force
git diff --cached # Verifica se ci sono cambiamenti nell'index
git commit -m "Updated license file and JSON file" || echo "No changes to commit"
git push