Skip to content

Github workflow to test Galaxy Lab changes #7

Github workflow to test Galaxy Lab changes

Github workflow to test Galaxy Lab changes #7

Workflow file for this run

name: Post link to lab
on:
pull_request:
types: [opened, synchronize]
jobs:
post-comment:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get list of changed files
id: changed-files
run: |
git fetch origin main
git diff --name-only origin/main..HEAD > changed_files.txt
echo ""
echo "Changed files:"
cat changed_files.txt
- name: Post comment if matching changes found
# if: contains(steps.changed-files.outputs.changes, 'communities/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
declare -A directories
FILES=$(cat changed_files.txt)
PR_NUMBER="${{ github.event.number }}"
USERNAME="${{ github.actor }}"
BRANCH_NAME="${{ github.head_ref }}"
for FILE in $FILES; do
if [[ "$FILE" == communities/*/lab/* ]]; then
NAME=$(echo "$FILE" | cut -d'/' -f2)
# Check if this directory has already been processed
if [[ -z "${directories[$NAME]}" ]]; then
echo "Posting link for ${NAME}..."
directories[$NAME]=1
cat <<EOF > comment.md
### Preview changes to ${NAME} Lab
https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/base.yml
- [usegalaxy.org.yml](https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/usegalaxy.org.yml)
- [usegalaxy.eu.yml](https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/usegalaxy.eu.yml)
- [usegalaxy.org.au.yml](https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/usegalaxy.org.au.yml)
EOF
gh pr comment "$PR_NUMBER" --body "$(cat comment.md)"
fi
else
echo "Ignoring changes to $FILE: not in a lab directory"
fi
done