name: "Update Mozilla CA sub module"
on:
  workflow_dispatch:

jobs:
  update_ca_module:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          repository: chia-network/chia-blockchain
          submodules: recursive
          token: "${{ secrets.GITHUB_TOKEN }}"

      - name: Set up commit signing
        uses: Chia-Network/actions/commit-sign/gpg@main
        with:
          gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY }}
          passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}

      - name: "Add changes to new branch"
        run: |
          cd ./mozilla-ca
          git pull origin main

      - name: "Create Pull Request"
        uses: peter-evans/create-pull-request@v7
        with:
          base: main
          body: "Newest Mozilla CA cert"
          branch: mozilla-ca-updates
          commit-message: "adding ca updates"
          delete-branch: true
          reviewers: "wjblanke,emlowe"
          assignees: "wallentx"
          title: "CA Cert updates"
          token: "${{ secrets.GITHUB_TOKEN }}"
          committer: "ChiaAutomation <automation@chia.net>"
          author: "ChiaAutomation <automation@chia.net>"
