From 05a6326c9b9eb75304e192204f59a238f3466805 Mon Sep 17 00:00:00 2001 From: Tomek Date: Thu, 20 Feb 2025 01:02:52 +0100 Subject: [PATCH] updated PR pipeline --- .github/workflows/pull_request.yaml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 0e25109..677a3ef 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -33,25 +33,31 @@ jobs: echo "Running test deployment" poetry run -P vyos sync -i ./inventory.yaml -v -m -t - name: Read files content and create PR comment - uses: actions/github-script@v7 + uses: actions/github-script@v6 with: - github-token: ${{ secrets.TOKEN }} + github-token: ${{ secrets.ROBOT_TOKEN }} script: | const fs = require('fs'); - const files = fs.readdirSync('changes'); + const path = 'changes'; let content = ''; - if (files.length === 0) { + if (!fs.existsSync(path)) { content = 'No changes will be applied'; } else { - files.forEach(file => { - const fileContent = fs.readFileSync(`changes/${file}`, 'utf8'); - content += `\n\n${fileContent}`; - }); + const files = fs.readdirSync(path); + if (files.length === 0) { + content = 'No changes will be applied'; + } else { + content = 'With this PR you\'ll apply these changes:'; + files.forEach(file => { + const fileContent = fs.readFileSync(`${path}/${file}`, 'utf8'); + content += `\n\n${fileContent}`; + }); + } } - const commentBody = `Hello! With this PR you'll apply these changes:\n\n${content}`; + const commentBody = `Hello! ${content}`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: commentBody - }); \ No newline at end of file + });