mirror of
https://github.com/EbookFoundation/free-programming-books.git
synced 2024-12-22 11:26:14 +00:00
9c550dd5a1
Some checks failed
Check URLs from changed files / Get changed files (push) Has been cancelled
Detect conflicting PRs / Detect (push) Has been cancelled
Check URLs from changed files / Check @ ${{ matrix.file }} (push) Has been cancelled
Check URLs from changed files / GitHub report (push) Has been cancelled
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 45.0.4 to 45.0.5. - [Release notes](https://github.com/tj-actions/changed-files/releases) - [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md) - [Commits](https://github.com/tj-actions/changed-files/compare/v45.0.4...v45.0.5) --- updated-dependencies: - dependency-name: tj-actions/changed-files dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
133 lines
4.7 KiB
YAML
133 lines
4.7 KiB
YAML
name: Check URLs from changed files
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
permissions:
|
|
# needed for checkout code
|
|
contents: read
|
|
|
|
# This allows a subsequently queued workflow run to interrupt/wait for previous runs
|
|
concurrency:
|
|
group: '${{ github.workflow }} @ ${{ github.run_id }}'
|
|
cancel-in-progress: false # true = interrupt, false = wait
|
|
|
|
jobs:
|
|
|
|
# NOTE: tj-actions/changed-files.
|
|
# For push events you need to include fetch-depth: 0 | 2 depending on your use case.
|
|
# 0: retrieve all history for all branches and tags
|
|
# 1: retrieve only current commit (by default)
|
|
# 2: retrieve until the preceding commit
|
|
get-changed-files:
|
|
name: Get changed files
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
fetch-depth: ${{ steps.set-params.outputs.fetch-depth }}
|
|
files: ${{ steps.set-files.outputs.files }}
|
|
files-len: ${{ steps.set-files.outputs.files-len }}
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- name: Determine workflow params
|
|
id: set-params
|
|
run: |
|
|
echo "fetch_depth=0" >> $GITHUB_OUTPUT
|
|
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
|
echo "fetch_depth=0" >> $GITHUB_OUTPUT
|
|
fi
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: ${{ steps.set-params.outputs.fetch-depth }}
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@v45.0.5
|
|
with:
|
|
separator: " "
|
|
json: true
|
|
- id: set-files
|
|
run: |
|
|
echo "${{ steps.changed-files.outputs.all_changed_files }}" \
|
|
| jq --raw-output '. | join(" ")' \
|
|
| sed -e 's/^/files=/' \
|
|
>> $GITHUB_OUTPUT
|
|
echo "${{ steps.changed-files.outputs.all_changed_files }}" \
|
|
| jq --raw-output '. | length' \
|
|
| sed -e 's/^/files-len=/' \
|
|
>> $GITHUB_OUTPUT
|
|
- id: set-matrix
|
|
run: |
|
|
echo "{\"file\":${{ steps.changed-files.outputs.all_changed_files }}}" \
|
|
| sed -e 's/^/matrix=/' \
|
|
>> $GITHUB_OUTPUT
|
|
|
|
|
|
check-urls:
|
|
name: Check @ ${{ matrix.file }}
|
|
if: ${{ fromJSON(needs.get-changed-files.outputs.files-len) > 0 }}
|
|
needs: [get-changed-files]
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.get-changed-files.outputs.matrix) }}
|
|
max-parallel: 10
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout
|
|
if: ${{ endsWith(matrix.file, '.yml') || endsWith(matrix.file, '.md') }}
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: ${{ needs.get-changed-files.outputs.fetch-depth }}
|
|
- name: Setup Ruby v2.6
|
|
if: ${{ endsWith(matrix.file, '.yml') || endsWith(matrix.file, '.md') }}
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 2.6
|
|
- name: Install awesome_bot
|
|
if: ${{ endsWith(matrix.file, '.yml') || endsWith(matrix.file, '.md') }}
|
|
run: |
|
|
gem install awesome_bot
|
|
- name: Set output
|
|
id: set-output
|
|
# FILENAME takes the complete file path and strips everything before the final '/'
|
|
# FILEPATH replaces all '/' with '-' in the file path since '/' is not allowed in upload artifact name
|
|
# Due to a bug in actions/download-artifact, we need to rename README.md to BASE_README.md
|
|
run: |
|
|
echo "FILENAME=$(echo ${{ matrix.file }} | grep -oE '[a-zA-Z0-9_-]+(\.yml|\.md)')" >> "$GITHUB_OUTPUT"
|
|
|
|
file_path="${{ matrix.file }}"
|
|
file_path="${file_path//\//-}"
|
|
|
|
if [[ "$file_path" == "README.md" ]]; then
|
|
file_path="BASE_README.md"
|
|
fi
|
|
|
|
echo "FILEPATH=${file_path}" >> "$GITHUB_OUTPUT"
|
|
- name: "Check URLs of file: ${{ matrix.file }}"
|
|
if: ${{ endsWith(matrix.file, '.yml') || endsWith(matrix.file, '.md') }}
|
|
run: |
|
|
awesome_bot "${{ matrix.file }}" --allow-redirect --allow-dupe --allow-ssl || true;
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.set-output.outputs.FILEPATH }}
|
|
path: ${{ github.workspace }}/ab-results-*.json
|
|
|
|
|
|
reporter:
|
|
name: GitHub report
|
|
needs: [get-changed-files, check-urls]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout # for having the sources of the local action
|
|
uses: actions/checkout@v4
|
|
# download and unzip the ab-results-*.json generated by job-matrix: check-urls
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
- name: Generate Summary Report
|
|
uses: ./.github/actions/awesomebot-gh-summary-action
|
|
with:
|
|
ab-root: ${{ github.workspace }}
|
|
files: ${{ needs.get-changed-files.outputs.files }}
|
|
separator: " "
|
|
append-heading: ${{ true }}
|