Add comment to CoC document warning about local modifications (#283) #6
This file contains hidden or 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: Update Code of Conduct | |
| on: | |
| push: | |
| branches: ['main'] | |
| paths: ['CODE_OF_CONDUCT.md'] | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| plan-coc-update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| repo_list: ${{ steps.repo_list.outputs.repo_list }} | |
| commit_hash: ${{ steps.commit_hash.outputs.commit_hash }} | |
| steps: | |
| - name: Checkout this repository | |
| uses: actions/checkout@v6 | |
| - name: Get latest commit hash | |
| id: commit_hash | |
| run: | | |
| commit_hash=$(git rev-parse --short=16 HEAD) | |
| echo "commit_hash=$commit_hash" >> $GITHUB_OUTPUT | |
| - name: Get list of repositories | |
| id: repo_list | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| repo_list=$(gh repo list $GITHUB_REPOSITORY_OWNER --no-archived --json nameWithOwner --jq ".[].nameWithOwner") | |
| jq_repo_list=$(jq -c -n '$ARGS.positional' --args ${repo_list[@]}) | |
| echo repo_list="$jq_repo_list" >> $GITHUB_OUTPUT | |
| update-coc: | |
| runs-on: ubuntu-latest | |
| needs: plan-coc-update | |
| strategy: | |
| matrix: | |
| full_repo: ${{ fromJson(needs.plan-coc-update.outputs.repo_list) }} | |
| steps: | |
| - name: Checkout this repo | |
| uses: actions/checkout@v6 | |
| with: | |
| path: sourcerepo | |
| - name: Checkout repo to be updated | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ matrix.full_repo }} | |
| path: targetrepo | |
| token: ${{ secrets.BRUTUS_PAT_TOKEN }} | |
| - name: Update Code of Conduct | |
| env: | |
| GH_TOKEN: ${{ secrets.BRUTUS_PAT_TOKEN }} | |
| run: | | |
| # Ignore changes to this repo | |
| if [[ "${{ matrix.full_repo }}" == "$GITHUB_REPOSITORY" ]]; then | |
| echo "Skipping source repository ($GITHUB_REPOSITORY)..." | |
| exit 0 | |
| fi | |
| # Work within target repo | |
| cd targetrepo | |
| # Set the author information to Brutus | |
| git config --local user.email "brutus@beeware.org" | |
| git config --local user.name "Brutus (robot)" | |
| # Make new branch for change | |
| echo "Creating new branch..." | |
| timestamp=$(date +%m%d%Y-%H%M%S) | |
| branch_name="coc-update-$timestamp" | |
| git checkout -b $branch_name | |
| # Add the new code of conduct | |
| echo "Replacing Code of Conduct..." | |
| cp ../sourcerepo/CODE_OF_CONDUCT.md . | |
| # Commit and push the update | |
| echo "Syncing updates to remote..." | |
| git add CODE_OF_CONDUCT.md | |
| git commit -m "Updated Code of Conduct ($GITHUB_REPOSITORY, ${{ needs.plan-coc-update.outputs.commit_hash }})" | |
| git push --set-upstream origin "$branch_name" | |
| # Create the pull request | |
| echo "Creating pull request..." | |
| gh pr create \ | |
| --repo ${{ matrix.full_repo }} \ | |
| --title "Update Code of Conduct" \ | |
| --body "Updated via $GITHUB_REPOSITORY (${{ needs.plan-coc-update.outputs.commit_hash }})" |