Skip to content

fix-the-autoannotate-metadata-workflow #86

fix-the-autoannotate-metadata-workflow

fix-the-autoannotate-metadata-workflow #86

name: AutocompleteMetadata
on:
pull_request_target:
paths:
- 'Molecules/membrane/**/metadata.yaml'
- 'Molecules/solution/**/metadata.yaml'
permissions:
contents: read
pull-requests: write
jobs:
add-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout BilayerData
uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false
- name: Clone Databank and install
run: |
git clone --depth 1 https://github.com/NMRlipids/FAIRMD_lipids.git "$RUNNER_TEMP/Databank"
pip install "$RUNNER_TEMP/Databank"
- name: Install the gh cli
uses: ksivamuthu/actions-setup-gh-cli@v3
with:
version: 2.83.0
- name: Find changed metadata.yaml files
id: files
env:
GH_TOKEN: ${{ github.token }}
run: |
changed_files=$(gh api --paginate \
"repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \
--jq '.[] | select(.status != "removed") | .filename' \
| grep -E '^Molecules/(membrane|solution)/[^/]+/metadata\.yaml$' || true)
{
echo "changed_files<<EOF"
echo "$changed_files"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "Changed files:"
echo "$changed_files"
- name: Run AddMetadata.py and create suggestions
if: steps.files.outputs.changed_files != ''
env:
CHANGED_FILES: ${{ steps.files.outputs.changed_files }}
run: |
printf '%s\n' "$CHANGED_FILES" | while IFS= read -r f; do
[ -n "$f" ] && python "$RUNNER_TEMP/Databank/developer/autocomplete_metadata.py" "$f"
done
- name: Suggest changes on PR
if: steps.files.outputs.changed_files != ''
uses: reviewdog/action-suggester@v1
with:
tool_name: addmetadata
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_level: any # surface errors instead of exiting 0
reviewdog_flags: -tee # echo reviewdog's stdout/stderr to the log