Extract CI sync actions into their own file (#711)

This commit is contained in:
Nicholas Wilson
2025-03-01 09:12:05 +00:00
committed by GitHub
parent 773486b4b5
commit 02a0166265
5 changed files with 105 additions and 99 deletions

View File

@@ -441,64 +441,3 @@ jobs:
- name: Test
run: bazelisk test //... --enable_runfiles --incompatible_strict_action_env --test_output=all
heron:
# Job to verify that the tasks performed by UpdateAlways have been done. It is
# the committer's responsibility (currently) to run UpdateAlways themselves when
# making a PR, so that everything is kept in-sync.
name: Check autogenerated file freshness
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: false
fetch-depth: 0 # Necessary for maint/UpdateAlways
fetch-tags: false
# Check out the unmerged source branch for `pull_request`-triggered runs;
# otherwise use the tip of the branch for `workflow_dispatch` and `pull` triggers.
ref: ${{ github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: UpdateDates
if: |
github.event_name != 'pull_request' &&
(startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/pcre2-'))
run: maint/UpdateDates.py
- name: UpdateAlways
run: maint/UpdateAlways
- name: 'Rebuild *.h.generic'
run: |
./autogen.sh && ./configure
# Workaround for incorrect filesystem permissions on /usr/share/aclocal, which
# causes the m4 macros to be copied with incorrect permissions.
# https://github.com/actions/runner-images/issues/11212
chmod u=rw,go=r m4/*.m4
rm -f src/*.generic
make src/config.h.generic src/pcre2.h.generic
# If we're in a forked repo, it's too onerous to expect contributors to run the
# checks locally to keep these files up to date (since the tool versions are very
# fussy and brittle).
#
# However, we still want to run the steps above, to check that the UpdateAlways
# process is able to run to completion, since it can pick up errors in the man pages.
- name: Commit and push, if not in a forked repo
if: github.event_name != 'pull_request' || ( ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' )
run: |
if [ -n "`git status --porcelain`" ] ; then
# Dirty working tree: push it
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u
git commit -m "Sync autogenerated files #noupdate"
git push
fi

View File

@@ -2,9 +2,10 @@ name: Deploy Pages
on:
workflow_dispatch:
workflow_run:
workflows: [ 'Sync doc changes' ]
workflows: [ 'Sync' ]
types:
- completed
branches: [ master ]
push:
branches: [ pages ]
pull_request:

102
.github/workflows/sync.yml vendored Normal file
View File

@@ -0,0 +1,102 @@
name: Sync
on:
workflow_dispatch:
push:
branches: [ master, "release/**" ]
pull_request:
branches: [ master ]
permissions:
contents: read
jobs:
sync-autogenerated:
# Job to verify that the tasks performed by UpdateAlways have been done. It is
# the committer's responsibility (currently) to run UpdateAlways themselves when
# making a PR, so that everything is kept in-sync.
name: Check autogenerated file freshness
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: false
fetch-depth: 0 # Necessary for maint/UpdateAlways
fetch-tags: false
# Check out the unmerged source branch for `pull_request`-triggered runs;
# otherwise use the tip of the branch for `workflow_dispatch` and `pull` triggers.
ref: ${{ github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: UpdateDates
if: |
github.event_name != 'pull_request' &&
(startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/pcre2-'))
run: maint/UpdateDates.py
- name: UpdateAlways
run: maint/UpdateAlways
- name: 'Rebuild *.h.generic'
run: |
./autogen.sh && ./configure
# Workaround for incorrect filesystem permissions on /usr/share/aclocal, which
# causes the m4 macros to be copied with incorrect permissions.
# https://github.com/actions/runner-images/issues/11212
chmod u=rw,go=r m4/*.m4
rm -f src/*.generic
make src/config.h.generic src/pcre2.h.generic
# If we're in a forked repo, it's too onerous to expect contributors to run the
# checks locally to keep these files up to date (since the tool versions are very
# fussy and brittle).
#
# However, we still want to run the steps above, to check that the UpdateAlways
# process is able to run to completion, since it can pick up errors in the man pages.
- name: Commit and push, if not in a forked repo
if: github.event_name != 'pull_request' || ( ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' )
run: |
if [ -n "`git status --porcelain`" ] ; then
# Dirty working tree: push it
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u
git commit -m "Sync autogenerated files #noupdate"
git push
fi
sync-docs:
name: Sync content from master to pages
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
needs: ['sync-autogenerated']
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: false
fetch-depth: 0 # Necessary to get both the master and pages branches
fetch-tags: false
ref: pages
- name: Commit and push, if docs have changed
run: |
if ! git diff --exit-code origin/master -- \
./doc ./AUTHORS.md ./LICENCE.md ./SECURITY.md ./README.md \
./README ./NON-AUTOTOOLS-BUILD >/dev/null ; then
# Differences from master: merge and push
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git merge origin/master --no-edit -m"Sync content from master to pages"
git push
else
echo "No content changes to sync"
fi

View File

@@ -1,36 +0,0 @@
name: Sync doc changes
on:
workflow_dispatch:
push:
branches: [ master ]
permissions:
contents: read
jobs:
sync-docs:
name: Sync content from master to pages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: false
fetch-depth: 0 # Necessary to get both the master and pages branches
fetch-tags: false
ref: pages
- name: Commit and push, if docs have changed
run: |
if ! git diff origin/master -- ./doc ./AUTHORS.md ./LICENCE.md ./SECURITY.md \
./README ./NON-AUTOTOOLS-BUILD >/dev/null ; then
# Differences from master: merge and push
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git merge origin/master --no-edit -m"Sync content from master to pages"
git push
else
echo "No content changes to sync"
fi

View File

@@ -47,4 +47,4 @@ AC_DEFUN([PCRE2_ZOS_FIXES],
fi
fi
])
])