From 8c98688bef9cf76561d89e22a862a98c227430fa Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 10:44:57 +1000 Subject: [PATCH 1/5] Add WF step to check HTTP status of changed lab(s) --- .github/workflows/link_labs.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 466c925a..98fd50bb 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -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: | @@ -49,8 +48,22 @@ jobs: 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" >> "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 From 565d569a375050bc91a0d854fc130acb9e5ba86e Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 10:48:34 +1000 Subject: [PATCH 2/5] Workflow post link on PR open only --- .github/workflows/link_labs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 98fd50bb..e11415c1 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -2,7 +2,7 @@ name: Post link to lab on: pull_request: - types: [opened, synchronize] + types: [opened, reopened] jobs: post-comment: From 40105476935b83b0614c325c2f272023f0ae9aa9 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 10:50:33 +1000 Subject: [PATCH 3/5] Add cache=false to lab urls --- .github/workflows/link_labs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index e11415c1..7db0da35 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -40,17 +40,17 @@ 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" >> "urls.txt" + 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" From af9a5be08be7f7ca004bdcaac9cfeadf6eb62ad2 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 10:51:26 +1000 Subject: [PATCH 4/5] Don't post link on PR reopen --- .github/workflows/link_labs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 7db0da35..1d8f733d 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -2,7 +2,7 @@ name: Post link to lab on: pull_request: - types: [opened, reopened] + types: [opened] jobs: post-comment: From 75c71e3d7757277635f602f7078c66d6300d000d Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 10:52:29 +1000 Subject: [PATCH 5/5] Rename workflow --- .github/workflows/link_labs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 1d8f733d..dd16cee5 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -1,4 +1,4 @@ -name: Post link to lab +name: Check Lab HTTP status on: pull_request: