diff --git a/.github/workflows/link_labs.yml b/.github/workflows/link_labs.yml new file mode 100644 index 00000000..99741c17 --- /dev/null +++ b/.github/workflows/link_labs.yml @@ -0,0 +1,52 @@ +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 --all + 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 <