-
Notifications
You must be signed in to change notification settings - Fork 43
chore(workflow): update updatemirror to add contributors list to REAdme #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ jobs: | |
| - ONLYOFFICE-data/build_tools_data | ||
|
|
||
| steps: | ||
| - name: Checkout runner workspace | ||
| - name: Mirror upstream repository | ||
| run: | | ||
| # Split repo name into owner and repo parts | ||
| IFS='/' read -r owner repo <<< "${{ matrix.repo }}" | ||
|
|
@@ -51,3 +51,72 @@ jobs: | |
| git push eurooffice --tags | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }} | ||
|
|
||
| - name: Update contributors list in README.md | ||
| run: | | ||
| IFS='/' read -r owner repo <<< "${{ matrix.repo }}" | ||
|
|
||
| # Clone the target repo default branch to update README | ||
| git clone --depth 1 "https://x-access-token:${{ env.GITHUB_TOKEN }}@github.com/Euro-Office/${repo}.git" "target-${repo}" | ||
| cd "target-${repo}" | ||
|
|
||
| # Identify README file | ||
| README_FILE=$(find . -maxdepth 1 -iname "readme.md" -print -quit) | ||
| [ -z "$README_FILE" ] && README_FILE="README.md" | ||
| [ ! -f "$README_FILE" ] && touch "$README_FILE" | ||
|
|
||
| # Remove existing contributors section and append updated list | ||
| sed -i '/## Contributors/,$d' "$README_FILE" | ||
| { | ||
| echo "" | ||
| echo "## Contributors" | ||
| echo "A huge thank you to all the contributors of the upstream repository!" | ||
| echo "" | ||
| gh api "repos/${{ matrix.repo }}/contributors" --jq '.[] | select(.type != "Bot") | "- [" + .login + "](" + .html_url + ")"' | ||
| } >> "$README_FILE" | ||
|
|
||
| # Commit and push changes | ||
| git config user.name "Euro-Office Robot" | ||
| git config user.email "eo-robot@users.noreply.github.com" | ||
| git add "$README_FILE" | ||
| if ! git diff --cached --quiet; then | ||
| git commit -m "chore: update contributors list in $README_FILE" | ||
| git push origin HEAD | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎. |
||
| fi | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }} | ||
|
|
||
| update-main-readme: | ||
| needs: build | ||
| runs-on: self-hosted | ||
| steps: | ||
| - name: Checkout DocumentServer | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| token: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }} | ||
|
|
||
| - name: Update contributors list in main README.md | ||
| run: | | ||
| README_FILE=$(find . -maxdepth 1 -iname "readme.md" -print -quit) | ||
| [ -z "$README_FILE" ] && README_FILE="README.md" | ||
|
|
||
| # Remove existing contributors section and append updated list | ||
| sed -i '/## Contributors/,$d' "$README_FILE" | ||
| { | ||
| echo "" | ||
| echo "## Contributors" | ||
| echo "A huge thank you to all the contributors of Euro-Office!" | ||
| echo "" | ||
| gh api "repos/${{ github.repository }}/contributors" --jq '.[] | select(.type != "Bot") | "- [" + .login + "](" + .html_url + ")"' | ||
| } >> "$README_FILE" | ||
|
|
||
| # Commit and push changes | ||
| git config user.name "Euro-Office Robot" | ||
| git config user.email "eo-robot@users.noreply.github.com" | ||
| git add "$README_FILE" | ||
| if ! git diff --cached --quiet; then | ||
| git commit -m "chore: update contributors list in $README_FILE" | ||
| git push origin HEAD | ||
| fi | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both contributor list updates call
gh api .../contributorswithout pagination, so only the first page is processed; thegh apimanual states that--paginateis required to fetch all pages. As a result, repositories with more than one page of non-bot contributors will have incomplete contributor sections, which undermines the stated goal of maintaining a full contributor list.Useful? React with 👍 / 👎.