diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index ba14b5dc..dd16cee5 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -1,8 +1,8 @@ -name: Post link to lab +name: Check Lab HTTP status on: pull_request: - types: [opened, reopened] + types: [opened] jobs: post-comment: @@ -21,7 +21,6 @@ jobs: 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: | @@ -41,16 +40,30 @@ jobs: cat < 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 + https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/base.yml&cache=false - - [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) + - [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&cache=false) + - [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&cache=false) + - [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&cache=false) EOF gh pr comment "$PR_NUMBER" --body "$(cat comment.md)" + + # Write url to file + echo "https://labs.usegalaxy.org.au/?content_root=https://github.com/${USERNAME}/galaxy_codex/blob/${BRANCH_NAME}/communities/${NAME}/lab/base.yml&cache=false" >> "urls.txt" fi else echo "Ignoring changes to $FILE: not in a lab directory" fi done + - name: Check URLs for Success Status Code + run: | + while IFS= read -r url; do + status_code=$(curl -o /dev/null -s -w "%{http_code}" "$url") + if [[ "$status_code" -ge 200 && "$status_code" -lt 300 ]]; then + echo "✅ $url returned a success status code: $status_code" + else + echo "❌ $url returned a failure status code: $status_code" + exit 1 + fi + done < urls.txt