- fixed incorrectly reported compositions, structure, and processing … #5
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: | | |
if ! compgen -G "*.csv" > /dev/null; then | |
echo "diff_count=0" >> $GITHUB_OUTPUT | |
echo "dois=" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
git add *.csv || true | |
if [ -z "$(git diff --cached)" ]; then | |
echo "diff_count=0" >> $GITHUB_OUTPUT | |
echo "dois=" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
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 | |
if: steps.diff.outputs.diff_count != '0' | |
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 | |
# Get DOIs from non-metadata changes | |
DOIS=$(git diff --cached -U0 | awk ' | |
/^@@/ { | |
split($3, a, ","); # Split the line number spec | |
lineno = substr(a[1], 2); # Remove the + and get the number | |
} | |
/^\+/ { | |
if (lineno > 6) { # Only process lines after metadata | |
print $0 | |
} | |
lineno++ | |
} | |
' | 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' |