Skip to content

Commit

Permalink
ci: setup submodule auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicoulaud-ledger committed Sep 24, 2024
1 parent 2ee28a8 commit 849de22
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
40 changes: 40 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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'
76 changes: 76 additions & 0 deletions .github/workflows/update_submodules.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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

0 comments on commit 849de22

Please sign in to comment.