diff --git a/.github/workflows/commit-bot.yml b/.github/workflows/commit-bot.yml index eb4d068470..cea574c3aa 100644 --- a/.github/workflows/commit-bot.yml +++ b/.github/workflows/commit-bot.yml @@ -1,5 +1,17 @@ name: Commit Bot +# Instructions +# +# - One-time setup: create a personal access token with permissions. Then configure it here +# as secrets.CI_PAT. https://github.com/boostorg/boost/settings/secrets/actions +# The reason is explained in https://github.com/orgs/community/discussions/25702 +# "If an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run" +# +# - Processing of either the 'master' or 'develop' branch may be stopped by creating the variables +# vars.block_master or vars.block_develop with any value. +# https://github.com/boostorg/boost/settings/variables/actions +# + # To avoid infinite loops, don't trigger on "push" on: schedule: @@ -19,12 +31,26 @@ jobs: - name: Check for module updates id: branches run: | - if [[ "${{ github.event_name }}" == "push" ]]; then - branches="${{ github.ref_name }}" - else - branches="master develop" - fi - echo "branches=$branches" >> $GITHUB_OUTPUT + set -xe + branches="" + if [[ "${{ github.event_name }}" == "push" ]]; then + if [[ ! -n "${{ vars.block_master }}" && "${{ github.ref_name }}" == "master" ]]; then + branches="master" + elif [[ ! -n "${{ vars.block_develop }}" && "${{ github.ref_name }}" == "develop" ]]; then + branches="develop" + else + branches="${{ github.ref_name }}" + fi + else + # from a schedule: + if [[ ! -n "${{ vars.block_master }}" ]]; then + branches="master" + fi + if [[ ! -n "${{ vars.block_develop }}" ]]; then + branches="${branches} develop" + fi + fi + echo "branches=$branches" >> $GITHUB_OUTPUT - name: Checkout master repository uses: actions/checkout@v4 @@ -45,11 +71,11 @@ jobs: - name: Check for module updates run: | branches="${{ steps.branches.outputs.branches }}" - - # Set up Git + + # Set up Git git config --global user.name "boost-commitbot" git config --global user.email "boost-commitbot@example.com" - + # Update each branch for branch in $branches; do cd $branch @@ -74,7 +100,7 @@ jobs: echo "$submodule_name ($commit_id): OK" else echo "$submodule_name: $previous_commit_id -> $commit_id" - set -x + set -x set +e git submodule update --init "$submodule_path" git submodule update --remote "$submodule_path" @@ -104,4 +130,3 @@ jobs: github_token: ${{ secrets.CI_PAT }} branch: develop directory: develop -