Compiled species for HCI database (aung-cc-pwcvqz) #30
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: repodata | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
generate_repodata: | |
runs-on: ubuntu-latest | |
name: Generate repodata.txt on data folders | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Update repodata.txt files | |
run: | | |
# Configure Git user details | |
git config --global user.email "qcdevs-bot@mail.com" | |
git config --global user.name "database-bot" | |
# Store current working directory | |
cwd=$(pwd) | |
# Update repodata.txt for each git-tracked directory not starting with '.' | |
for dir in $(git ls-tree -rtd --name-only HEAD ./ | grep -Ev '^\.'); do | |
# Temporarily `cd` to ${dir} to compute checksums and git operations | |
cd "${cwd}/${dir}" | |
# Get sorted basenames of files not starting with '.' and not named 'repodata.txt' | |
files=$(find . -maxdepth 1 -type f ! -name '.*' ! -name 'repodata.txt' -exec basename -a {} + | sort) | |
# If ${files} is non-empty, write SHA-256 checksums to 'repodata.txt' and then stage it | |
if [ -n "${files}" ]; then | |
sha256sum ${files} > 'repodata.txt' | |
git add 'repodata.txt' | |
fi | |
done | |
# Return to current working directory | |
cd "${cwd}" | |
- name: Commit repodata.txt file changes | |
run: | | |
# Commit and push changes if any have been staged by `git add` | |
if git diff --quiet --staged; then | |
git commit -m "Update repodata.txt" | |
git push origin main | |
fi |