Skip to content

Update license file #64

Update license file

Update license file #64

Workflow file for this run

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