Add [Linux (RPM/DEB/APK) installer packages] chinese version page (#2… #221
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Contributor Updater | |
on: | |
workflow_dispatch: | |
push: | |
paths: [ content/asciidoc-pages/** ] | |
branches: [ main ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check_contributors: | |
if: github.repository_owner == 'adoptium' | |
name: Check Contributors | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Get changed files | |
if: github.event_name == 'push' | |
id: files | |
run: | | |
changed_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}") | |
echo "all=$changed_files" >> "$GITHUB_OUTPUT" | |
- run: pip3 install bs4 | |
- run: | | |
# This function takes one argument, which is the path to a file. | |
# The function first checks if the file path matches a regular expression pattern for AsciiDoc files located in the "content/asciidoc" directory | |
# If the file path matches the pattern, the function extracts the current authors from the file using grep and sed. It then uses a Python script to determine the contributors to the file and loops through each contributor. | |
# For each contributor, the function checks if they are already listed as an author in the file. If not, it adds the contributor to the list of authors and updates the file using sed. | |
update_authors() { | |
local file=$1 | |
if [[ ${file} =~ ^content/asciidoc.*.adoc ]]; then | |
# If page is in a _partials directory, skip it | |
if [[ ${file} =~ ^content/asciidoc.*_partials.*.adoc ]]; then | |
return | |
fi | |
current_authors=$(grep ':page-authors:' "${file}" | sed -n -e 's/^.*page-authors: //p') | |
contibutors=$(python3 .github/workflows/github-file-contributors.py --file "${file}") | |
for contibutor in ${contibutors}; do | |
if ! echo "${current_authors}" | grep "${contibutor}"; then | |
echo "adding ${contibutor}" | |
current_authors_replacement="${current_authors}, ${contibutor}" | |
echo "${current_authors_replacement}" | |
sed -i "s/${current_authors}/${current_authors_replacement}/g" "${file}" | |
fi | |
done | |
fi | |
} | |
# if workflow_dispatch, then we need to get all asciidoc files | |
if [[ -z "${{ steps.files.outputs.all }}" ]]; then | |
find content/asciidoc-pages -name '*.adoc' -type f | while read -r changed_file; do | |
update_authors "${changed_file}" | |
done | |
else | |
# shellcheck disable=2043 | |
for changed_file in ${{ steps.files.outputs.all }}; do | |
update_authors "${changed_file}" | |
done | |
fi | |
- uses: gr2m/create-or-update-pull-request-action@86ec1766034c8173518f61d2075cc2a173fb8c97 # v1.9.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ADOPTIUM_BOT_TOKEN }} | |
with: | |
title: "Update Asciidoc Contributors" | |
body: "This is an automatically generated pull request, it will be automatically merged if all the CI tests pass." | |
path: "content/asciidoc-pages/" | |
branch: "contributor_bot" | |
commit-message: "contributors: update asciidoc contributors" | |
labels: automerge | |
author: "adoptium-bot <adoptium-bot@eclipse.org>" |