From 2f5997d05994ff606a2863f59f973af766ebcadb Mon Sep 17 00:00:00 2001 From: Thomas Cardin <49320132+ThomasCardin@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:47:43 -0500 Subject: [PATCH] issue #71: Fixing the markdown check and repo standard workflow (#72) * isse #71: changed secrets for branch protection inside repo standard * issue #71: changed GITHUB_TOKEN to the previous one * issue #71: fixed repo-standards and markdown check * issue #71: fixed repo-standard workflow by changing branch to ref * issue #71: fixed repo standards workflow * issue #71: fixed typo * issue #71: code formatting --- .github/workflows/workflow-markdown-check.yml | 2 +- .../workflow-repo-standards-validation.yml | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/workflow-markdown-check.yml b/.github/workflows/workflow-markdown-check.yml index e9d248c..4e1d3e3 100644 --- a/.github/workflows/workflow-markdown-check.yml +++ b/.github/workflows/workflow-markdown-check.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@master + uses: actions/checkout@v4 - name: Validating links uses: gaurav-nelson/github-action-markdown-link-check@v1 diff --git a/.github/workflows/workflow-repo-standards-validation.yml b/.github/workflows/workflow-repo-standards-validation.yml index 5412f05..f3c1987 100644 --- a/.github/workflows/workflow-repo-standards-validation.yml +++ b/.github/workflows/workflow-repo-standards-validation.yml @@ -80,15 +80,24 @@ jobs: with: script: | const { owner, repo } = context.repo; + let refBranchNumber; + + if (context.eventName === 'pull_request') { + refBranchNumber = context.payload.pull_request.head.ref; + } else { + refBranchNumber = process.env['GITHUB_REF'].replace('refs/heads/', ''); + } + try { await github.rest.repos.getContent({ owner, repo, - path: 'README.md' + path: `README.md`, + ref: refBranchNumber }); } catch (error) { if (error.status === 404) { - core.setFailed("The repository does not have a README.md file, please add one."); + core.setFailed(`The ${refBranchNumber} branch does not have a README.md file, please add one.`); } else { core.setFailed(`An error occurred while checking for README: ${error.message}`); } @@ -100,21 +109,31 @@ jobs: with: script: | const { owner, repo } = context.repo; + let refBranchNumber; + + if (context.eventName === 'pull_request') { + refBranchNumber = context.payload.pull_request.head.ref; + } else { + refBranchNumber = process.env['GITHUB_REF'].replace('refs/heads/', ''); + } + try { await github.rest.repos.getContent({ owner, repo, - path: 'TESTING.md' + path: `TESTING.md`, + ref: refBranchNumber }); } catch (error) { if (error.status === 404) { - core.setFailed("The repository does not have a TESTING.md file, please add one."); + core.setFailed(`The ${refBranchNumber} branch does not have a TESTING.md file, please add one.`); } else { core.setFailed(`An error occurred while checking for TESTING.md: ${error.message}`); } } if: always() # Run step even if previous steps fail. + - name: Check if all files end in newline uses: fernandrone/linelint@master id: linelint