- added metadata change tracking to the excel2csv
action
#6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: excel2csv | |
on: [push] | |
jobs: | |
run: | |
name: excel2csv | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
cache-dependency-path: 'pyqalloy-contribute/requirements.txt' | |
- name: Install Dependencies | |
run: | | |
python -m pip install -r pyqalloy-contribute/requirements.txt | |
- name: Run excel2csv | |
run: | | |
python pyqalloy-contribute/pyqalloy-contribute/excel2csv.py . | |
- name: Calculate diff | |
id: diff | |
run: | | |
git add *.csv | |
DIFF_COUNT=$(git diff --cached --numstat | awk '{sum += $1 + $2} END {print sum}') | |
echo "diff_count=$DIFF_COUNT" >> $GITHUB_OUTPUT | |
- name: Check for changes in the metadata of uploaded files and then extract changing DOIs and add them to a set | |
id: dois | |
run: | | |
METADATA_PREFIX="" | |
if git diff --cached -U0 | grep '^@@' | awk -F'[,+ ]' '{if ($3 <= 6) exit 0; else exit 1}'; then | |
METADATA_PREFIX="\`metadata\`, " | |
fi | |
DOIS=$(git diff --cached -U0 | awk '/^@@/{p=1;if($3>6){p=1}else{p=0}}/^[+-]/{if(p==1)print}' | grep -v '^+++\|^---' | awk -F',' '{print "`" $NF "`"}' | sort -u | tr '\n' ' ') | |
echo "dois=$METADATA_PREFIX$DOIS" >> $GITHUB_OUTPUT | |
- name: Commit changes with Add & Commit | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: '(auto) Data Tracking Action changed `${{ steps.diff.outputs.diff_count }}` lines / data points [Changed DOIs: ${{ steps.dois.outputs.dois }}]' | |
add: '*.csv' |