From 849de22ee910be0ba43c613f2c8d188d09f721bc Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Tue, 24 Sep 2024 11:39:52 +0200 Subject: [PATCH] ci: setup submodule auto-update --- .github/labeler.yml | 4 ++ .github/workflows/automerge.yml | 40 +++++++++++++ .github/workflows/update_submodules.yml | 76 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/update_submodules.yml diff --git a/.github/labeler.yml b/.github/labeler.yml index 09e284d..1e0a57c 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -13,3 +13,7 @@ sources: dependencies: - changed-files: - any-glob-to-any-file: ['pdm.lock'] + +submodules: + - changed-files: + - any-glob-to-any-file: ['clear-signing-erc7730-registry'] diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..320212e --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,40 @@ +name: auto merge pull requests + +on: + pull_request: + types: + - labeled + - unlabeled + - synchronize + - opened + - edited + - ready_for_review + - reopened + - unlocked + pull_request_review: + types: + - submitted + check_suite: + types: + - completed + status: {} + +jobs: + automerge: + runs-on: ledgerhq-shared-small + timeout-minutes: 60 + steps: + + - name: Automatically merge pull requests + timeout-minutes: 60 + uses: gsoc2/automerge-action@v0.16.2 + env: + GITHUB_TOKEN: "${{ secrets.CI_BOT_TOKEN }}" + MERGE_LABELS: automerge + MERGE_METHOD: squash + MERGE_FILTER_AUTHOR: '^(dependabot|renovate|ldg-github-ci)$' + MERGE_FORKS: false + MERGE_RETRIES: 120 + MERGE_RETRY_SLEEP: 30 + MERGE_DELETE_BRANCH: true + BASE_BRANCHES: 'next' diff --git a/.github/workflows/update_submodules.yml b/.github/workflows/update_submodules.yml new file mode 100644 index 0000000..b6a2bd5 --- /dev/null +++ b/.github/workflows/update_submodules.yml @@ -0,0 +1,76 @@ +name: update submodules + +on: + schedule: + - cron: '0 7 * * *' + repository_dispatch: + types: [submodules] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + HEAD_BRANCH: "update_submodules" + BASE_BRANCH: "main" + +jobs: + update_submodules: + name: update submodules + runs-on: ledgerhq-shared-small + timeout-minutes: 60 + steps: + + - name: Checkout + timeout-minutes: 10 + uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + + - name: Fetch all branches + timeout-minutes: 10 + run: git fetch origin +refs/heads/*:refs/remotes/origin/* + + - name: Check if ${{ env.BASE_BRANCH }} branch exists + id: check_next_branch + run: | + if git show-ref --quiet refs/remotes/origin/${{ env.BASE_BRANCH }}; then + echo "${{ env.BASE_BRANCH }} branch already exists." + echo "branch_exists=true" >> $GITHUB_OUTPUT + else + echo "${{ env.BASE_BRANCH }} branch does not exist." + echo "branch_exists=false" >> $GITHUB_OUTPUT + fi + + - name: Create ${{ env.BASE_BRANCH }} branch if it doesn't exist + if: steps.check_next_branch.outputs.branch_exists == 'false' + run: | + git checkout -b ${{ env.BASE_BRANCH }} + git push origin ${{ env.BASE_BRANCH }} + + - name: Update Submodules + id: submodules + uses: sgoudham/update-git-submodules@v2.1.1 + + - name: Get date + run: echo "CURRENT_DATE=$(date)" >> $GITHUB_ENV + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.CI_BOT_TOKEN }} + commit-message: Update submodules + signoff: false + author: ${{ secrets.CI_BOT_USERNAME }} <${{ secrets.CI_BOT_USERNAME }}@users.noreply.github.com> + branch: ${{ env.HEAD_BRANCH }} + base: ${{ env.BASE_BRANCH }} + delete-branch: false + add-paths: | + inputs/* + outputs/* + title: 'chore: update submodules - ${{ env.CURRENT_DATE }}' + body: ${{ steps.submodules.outputs.prBody }} + labels: assets,automerge + draft: false