From 9e519c72ba4201732af1acbe6cd8eda9b053f836 Mon Sep 17 00:00:00 2001 From: Birajit Saikia Date: Wed, 29 Jan 2025 21:57:09 +0530 Subject: [PATCH 1/2] Validate external URLs in CI using Lychee --- .github/workflows/cd.yaml | 13 +++++++++++++ .github/workflows/link-check.yml | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/link-check.yml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 0279984d..6cd7956e 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -8,7 +8,20 @@ on: - completed jobs: + validate-urls: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install lychee + run: cargo install lychee + + - name: Check external links + run: lychee --verbose --exclude-mail --no-progress ./**/*.md + maven-cd: + needs: validate-urls uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1 secrets: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml new file mode 100644 index 00000000..8f507f87 --- /dev/null +++ b/.github/workflows/link-check.yml @@ -0,0 +1,21 @@ +name: Check External Links + +on: + pull_request: + push: + branches: + - main + +jobs: + link-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install lychee + run: cargo install lychee + + - name: Run lychee to check links + run: lychee --verbose --exclude-mail --no-progress ./**/*.md From d9a859b3f51da53979c371a41d464e33e0935e58 Mon Sep 17 00:00:00 2001 From: Birajit Saikia Date: Wed, 29 Jan 2025 22:13:31 +0530 Subject: [PATCH 2/2] fixed issues --- .github/workflows/cd.yaml | 10 +++++++++- .github/workflows/link-check.yml | 12 ++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 6cd7956e..e6740094 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -18,7 +18,15 @@ jobs: run: cargo install lychee - name: Check external links - run: lychee --verbose --exclude-mail --no-progress ./**/*.md + id: check_links + run: lychee --verbose --exclude-mail --no-progress ./**/*.md | tee lychee-output.txt + + - name: Fail CI if broken links exist + run: | + if grep -q "🚫" lychee-output.txt; then + echo "❌ Broken links found! CI is failing." + exit 1 + fi maven-cd: needs: validate-urls diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 8f507f87..9d760321 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -1,4 +1,4 @@ -name: Check External Links +name: Validate External Links on: pull_request: @@ -18,4 +18,12 @@ jobs: run: cargo install lychee - name: Run lychee to check links - run: lychee --verbose --exclude-mail --no-progress ./**/*.md + id: lychee_check + run: lychee --verbose --exclude-mail --no-progress ./**/*.md | tee lychee-output.txt + + - name: Fail CI if broken links exist + run: | + if grep -q "🚫" lychee-output.txt; then + echo "Broken links found! CI is failing." + exit 1 + fi