mirror of
https://github.com/EbookFoundation/free-programming-books.git
synced 2025-08-29 18:40:36 +02:00
ci(check-urls): fix push crash on new branch creation + render awesome_bot report (#7046)
* format: expand events
* format: add blank lines between steps of check job
* format: to run steps using multiline format
* feat: group for each output
* fix: solve crash on first push (trilom 2 tj action)
* chore: upload ab-results as `awesomebot-results.zip` artifact
* feat: changed files as workflow output
* feat: Generate GitHub Summary using `ab-results-*.json`s
* security: limit access rights with `contents: read`
Seen at PR #7043
Cherry picked from 50300ca119
Co-authored-by: Alex <93376818+sashashura@users.noreply.github.com>
* chore: setup concurrency policy
* chore: modularize using composite actions
Co-authored-by: Alex <93376818+sashashura@users.noreply.github.com>
This commit is contained in:
79
.github/workflows/check-urls.yml
vendored
79
.github/workflows/check-urls.yml
vendored
@@ -1,24 +1,81 @@
|
||||
name: Check URLs from changed files
|
||||
on: [push, pull_request]
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# This allows a subsequently queued workflow run to interrupt previous runs
|
||||
concurrency:
|
||||
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref || github.run_id }}'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
job:
|
||||
permissions:
|
||||
# Needed for the 'trilom/file-changes-action' action
|
||||
pull-requests: read
|
||||
check-urls:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
|
||||
steps:
|
||||
|
||||
# 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 current commit (by default)
|
||||
# 2: retrieve the preceding commit
|
||||
- name: Determine workflow parameters
|
||||
id: init-params
|
||||
run: |
|
||||
echo "::set-output name=fetch_depth::0";
|
||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||
echo "::set-output name=fetch_depth::1";
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: trilom/file-changes-action@v1.2.4
|
||||
id: file_changes
|
||||
with:
|
||||
output: ''
|
||||
fetch-depth: ${{ steps.init-params.outputs.fetch_depth }}
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v29.0.1
|
||||
with:
|
||||
separator: " "
|
||||
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: gem install awesome_bot
|
||||
- run: for i in ${{ steps.file_changes.outputs.files_modified }}; do echo; echo "processing $i"; awesome_bot $i --allow-redirect --allow-dupe --allow-ssl || true; done
|
||||
|
||||
- run: |
|
||||
gem install awesome_bot
|
||||
|
||||
- name: Check each changed file
|
||||
run: |
|
||||
# Set field separator
|
||||
IFS=$' ';
|
||||
|
||||
# Processing loop
|
||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
echo;
|
||||
echo "::group::Processing file... $file";
|
||||
awesome_bot "$file" --allow-redirect --allow-dupe --allow-ssl || true;
|
||||
echo "::endgroup::";
|
||||
done
|
||||
|
||||
# Unset field separator
|
||||
unset IFS;
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: ${{ github.workspace }}/*.json
|
||||
name: awesomebot-results
|
||||
path: ${{ github.workspace }}/ab-results-*.json
|
||||
|
||||
- name: Generate Summary Report using AwesomeBot results
|
||||
uses: ./.github/actions/awesomebot-gh-summary-action
|
||||
with:
|
||||
ab-root: ${{ github.workspace }}
|
||||
files: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
separator: " "
|
||||
append-heading: ${{ true }}
|
||||
|
Reference in New Issue
Block a user