GHA Autofill experiment #35
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: Prepare autofilled template for library metadata | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
Autofill: | |
# Only run if comment is on a PR with the main repo, and if it contains the magic keywords | |
if: > | |
contains(github.event.comment.html_url, '/pull/') && | |
startsWith(github.event.comment.body, '@spaam-bot please autofill') && | |
github.repository == 'SPAAM-community/AncientMetagenomeDir' | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
steps: | |
- uses: actions/checkout@v4 | |
# indication that the autofill is being attempted | |
- name: React on comment | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 | |
with: | |
comment-id: ${{ github.event.comment.id }} | |
reactions: eyes | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# install AMDirT | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
architecture: "x64" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install amdirt==1.5.0 | |
pip install jsonschema==4.17.0 | |
# Run the autofill script | |
- name: run autofill | |
run: | | |
table=$(echo "${{github.event.comment.body}}" | cut -d ' ' -f 4) | |
project=$(echo "${{github.event.comment.body}}" | cut -d ' ' -f 5) | |
set -o pipefail | |
bash assets/utility/autofill-wrapper.sh -t $table -p $project 2>&1 | tee autofill-log.txt | |
- uses: actions/upload-artifact@v4 | |
id: artifact-upload-step | |
with: | |
name: autofill-results | |
path: | | |
TEMPLATE_*libraries.tsv | |
autofill-log.txt | |
# Post results | |
- name: comment PR | |
if: always() | |
uses: mshick/add-pr-comment@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
message: | | |
<h1> | |
<picture> | |
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/SPAAM-community/AMDirT/blob/master/assets/logo_rectangular_dark.png?raw=true"> | |
<img width=30% alt="nf-core/taxprofiler" src="https://github.com/SPAAM-community/AMDirT/blob/master/assets/logo_rectangular.png?raw=true"> | |
</picture> | |
</h1> | |
### Autofill success! 🎉 | |
Download the attempted autofilled library file by pressing [this link](${{ steps.artifact-upload-step.outputs.artifact-url }}). | |
You can now fill in the remainder of the columns, and append to the end of the corresponding library file. | |
Please remember this service attempts to pull relevant metadata from the ENA, but metadata is not always correct! | |
> [!WARNING] | |
> Always check accuracy of pre-filled columns before adding to the library table! | |
refresh-message-position: true | |
message-failure: | | |
### Something went wrong 😢 | |
Please check your previous request (correct table, project ID etc.). | |
Request should be: | |
`@spaam-bot please autofill <table> <project_id>`. | |
Where `table` corresponds to an AncientMetagenomeDir, and `project_id` corresponds to the `project_id` you have added in your samples table (requires exact match!) | |
Otherwise please report on the #ancientmetagenomedir channel on the [SPAAM slack](https://www.spaam-community.org/about/). | |
Include the following URL: https://github.com/SPAAM-community/AncientMetagenomeDir/actions/runs/${{ github.run_id }} |