mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
We defined a github environment `book-sync` which contains the required secrets. After merging this PR we can remove the secrets from the per-repository secrets, which reduces the scope the secrets are available in, and has the added restriction of only being available on protected branches. Testing: Prior to this PR, the functionality was tested on the `environments` branch and discussed in the maintainers chat. After this PR is merged, a manual check should be done to ensure the book-export workflow still continues to work as expected. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
70 lines
2.8 KiB
YAML
70 lines
2.8 KiB
YAML
name: Book Export
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
upstream:
|
|
# Run job only on servo/servo
|
|
if: github.repository == 'servo/servo'
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: book-sync
|
|
deployment: false
|
|
steps:
|
|
- name: Check out Servo
|
|
uses: actions/checkout@v6
|
|
with:
|
|
sparse-checkout: |
|
|
python/servo/platform/linux_packages
|
|
fetch-depth: '2'
|
|
- name: Check out Servo book
|
|
uses: actions/checkout@v6
|
|
with:
|
|
path: book
|
|
repository: 'servo/book'
|
|
token: ${{ secrets.BOOK_SYNC_TOKEN }}
|
|
- name: Check for changes
|
|
working-directory: python/servo/platform/linux_packages
|
|
id: changes
|
|
run: |
|
|
# Note: This check assumes the action only runs on `main`.
|
|
if git diff --quiet HEAD HEAD^ -- . ; then
|
|
echo "No changes detected, exiting."
|
|
echo "CHANGES=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Changes detected, exporting book."
|
|
./generate_pkg_list.sh apt/apt_common.txt > ${{github.workspace}}/book/src/building/linux_packages/apt_common.txt
|
|
./generate_pkg_list.sh apt/apt_ubuntu_only.txt > ${{github.workspace}}/book/src/building/linux_packages/apt_ubuntu_only.txt
|
|
./generate_pkg_list.sh dnf/dnf_base.txt > ${{github.workspace}}/book/src/building/linux_packages/dnf_base.txt
|
|
./generate_pkg_list.sh xbps/xbps_base.txt > ${{github.workspace}}/book/src/building/linux_packages/xbps_base.txt
|
|
echo "CHANGES=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
- name: Commit changes
|
|
working-directory: book
|
|
if: ${{ steps.changes.outputs.CHANGES == 'true'}}
|
|
run: |
|
|
git config --local user.email "ghbot+book-sync@servo.org"
|
|
git config --local user.name "Book Sync Bot"
|
|
git add src/building/linux_packages/
|
|
git commit -m "linux: Update dependency list based on servo/servo@${GITHUB_SHA::13}"
|
|
- name: Push changes
|
|
if: ${{ steps.changes.outputs.CHANGES == 'true'}}
|
|
working-directory: book
|
|
run: git push 'https://${{ secrets.BOOK_SYNC_TOKEN }}@github.com/servo-bot/book.git' 'HEAD:linux_pkgs_sync_${{ github.sha }}'
|
|
- name: Open PR
|
|
if: ${{ steps.changes.outputs.CHANGES == 'true'}}
|
|
env:
|
|
GH_TOKEN: ${{ secrets.BOOK_SYNC_CREATE_PR_TOKEN }}
|
|
UPDATE_BRANCH: linux_pkgs_sync_${{ github.sha }}
|
|
working-directory: book
|
|
run: |
|
|
BODY=$(cat <<EOF
|
|
Update dependency list based on servo/servo@${GITHUB_SHA}
|
|
EOF
|
|
)
|
|
gh pr create \
|
|
--title "Sync Linux packages with servo (${GITHUB_SHA::7})" \
|
|
--repo servo/book \
|
|
--body "$BODY" --head servo-bot:${{ env.UPDATE_BRANCH }} |