From 3e5d0d2ebf358e443653f64d57a4baf487516fe1 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 06:02:49 +1000 Subject: [PATCH 1/6] Workflow to link to rendered lab webpages --- .github/workflows/link_labs.yml | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/link_labs.yml diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml new file mode 100644 index 00000000..081b7205 --- /dev/null +++ b/.github/workflows/link_labs.yml @@ -0,0 +1,54 @@ +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: Set up Git + run: git fetch origin main + + - name: Get list of changed files + id: changed-files + run: | + git diff --name-only origin/main...HEAD > changed_files.txt + 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" == ./my/repo/path/*/lab/* ]]; then + NAME=$(echo "$FILE" | cut -d'/' -f5) + # Check if this directory has already been processed + if [[ -z "${directories[$NAME]}" ]]; then + directories[$NAME]=1 + COMMENT=$(cat < Date: Wed, 30 Oct 2024 07:33:59 +1000 Subject: [PATCH 2/6] Fix yaml syntax error --- .github/workflows/link_labs.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 081b7205..6c00be51 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -38,16 +38,16 @@ jobs: if [[ -z "${directories[$NAME]}" ]]; then directories[$NAME]=1 COMMENT=$(cat < Date: Wed, 30 Oct 2024 07:37:59 +1000 Subject: [PATCH 3/6] Bump --- communities/spoc/lab/base.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/communities/spoc/lab/base.yml b/communities/spoc/lab/base.yml index 8fd77d1b..20f2cac0 100644 --- a/communities/spoc/lab/base.yml +++ b/communities/spoc/lab/base.yml @@ -66,3 +66,5 @@ sections: - sections/4_community.yml # ----------------------------------------------------------------------------- + +# Test comment From 77de7dd8c075c6d648007fa115e7fe7665754cfa Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 07:43:31 +1000 Subject: [PATCH 4/6] WIP fix workflow git fetch --- .github/workflows/link_labs.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml index 6c00be51..99741c17 100644 --- a/.github/workflows/link_labs.yml +++ b/.github/workflows/link_labs.yml @@ -11,12 +11,10 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Git - run: git fetch origin main - - name: Get list of changed files id: changed-files run: | + git fetch --all git diff --name-only origin/main...HEAD > changed_files.txt cat changed_files.txt From 63c62aadaaf4776f0f6fcdf147df10d17e9b42d0 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 07:43:54 +1000 Subject: [PATCH 5/6] Bump --- communities/spoc/lab/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communities/spoc/lab/base.yml b/communities/spoc/lab/base.yml index 20f2cac0..f8576e47 100644 --- a/communities/spoc/lab/base.yml +++ b/communities/spoc/lab/base.yml @@ -67,4 +67,4 @@ sections: # ----------------------------------------------------------------------------- -# Test comment +# Test comment . From a7f8b470f7e717f28b8337cafd7153dedfbc31b3 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Wed, 30 Oct 2024 07:49:46 +1000 Subject: [PATCH 6/6] Bump --- communities/spoc/lab/base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communities/spoc/lab/base.yml b/communities/spoc/lab/base.yml index f8576e47..20f2cac0 100644 --- a/communities/spoc/lab/base.yml +++ b/communities/spoc/lab/base.yml @@ -67,4 +67,4 @@ sections: # ----------------------------------------------------------------------------- -# Test comment . +# Test comment