name: Update Code of Conduct permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: workflow_dispatch: # Run every Sunday at midnight UTC (00:00) - triggered by webhook? schedule: - cron: "0 0 * * SUN" jobs: update_code_of_conduct: permissions: contents: write # needed for CoC PR pull-requests: write # needed for CoC PR runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false - name: Fetch CODE_OF_CONDUCT.md from django-commons run: | curl -o fetched_code_of_conduct.md https://raw.githubusercontent.com/django-commons/membership/main/CODE_OF_CONDUCT.md - name: Check if CODE_OF_CONDUCT.md has changed id: check_changes run: | if cmp -s fetched_code_of_conduct.md CODE_OF_CONDUCT.md; then echo "No changes in CODE_OF_CONDUCT.md" echo "changed=false" >> $GITHUB_OUTPUT else echo "CODE_OF_CONDUCT.md has changed" echo "changed=true" >> $GITHUB_OUTPUT cp fetched_code_of_conduct.md CODE_OF_CONDUCT.md fi # Create a pull request to merge the changes into the main branch - name: Create Pull Request if: steps.check_changes.outputs.changed == 'true' uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 with: token: ${{ secrets.GITHUB_TOKEN }} branch: bot-update-coc add-paths: | CODE_OF_CONDUCT.md title: "🤖 Update Code of Conduct 🤖" body: "Update the Code of Conduct with the latest version from the django-commons repository." commit-message: "Update CODE_OF_CONDUCT.md from django-commons"