diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8c6ddf8..dcd369b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,36 +1,36 @@ --- - name: Lint - on: - pull_request: - branches: [main] - paths: - - 'src/pages/**' - - jobs: - lint: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Lint - id: lint - continue-on-error: true - run: npx --yes github:AdobeDocs/adp-devsite-utils runLint -v +name: Lint +on: + pull_request: + branches: [main] + paths: + - 'src/pages/**' - - name: Post Linter Report to PR - if: always() - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_ID: ${{ github.event.pull_request.number }} - GITHUB_REPOSITORY: ${{ github.repository }} - run: | - npm install --no-save github:AdobeDocs/adp-devsite-scripts - node node_modules/adp-devsite-scripts/linter-bot/postLinterReport.js +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 - - name: Fail if linter found errors - if: steps.lint.outcome == 'failure' - run: exit 1 \ No newline at end of file + - name: Lint + id: lint + continue-on-error: true + run: npx --yes github:AdobeDocs/adp-devsite-utils runLint -v + + - name: Save PR number + if: always() + run: echo "${{ github.event.pull_request.number }}" > pr-number.txt + + - name: Upload linter report + if: always() + uses: actions/upload-artifact@v4 + with: + name: linter-report + path: | + linter-report.txt + pr-number.txt + + - name: Fail if linter found errors + if: steps.lint.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/post-lint-comment.yml b/.github/workflows/post-lint-comment.yml new file mode 100644 index 0000000..277a4b2 --- /dev/null +++ b/.github/workflows/post-lint-comment.yml @@ -0,0 +1,32 @@ +--- +name: Post Linter Report +on: + workflow_run: + workflows: ["Lint"] + types: + - completed + +permissions: + pull-requests: write + +jobs: + comment: + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' + steps: + - name: Download linter report artifact + uses: actions/download-artifact@v4 + with: + name: linter-report + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Post Linter Report to PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + LINTER_REPORT_PATH: ./linter-report.txt + PR_NUMBER_PATH: ./pr-number.txt + run: | + npm install --no-save github:AdobeDocs/adp-devsite-scripts + node node_modules/adp-devsite-scripts/linter-bot/postLinterReport.js