From 58b3880156f44526b261db830712ee3178183d0d Mon Sep 17 00:00:00 2001 From: Parth Aggarwal Date: Fri, 22 Nov 2024 16:32:26 -0800 Subject: [PATCH 1/3] Create update_parent_repos.yml --- .github/workflows/update_parent_repos.yml | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/update_parent_repos.yml diff --git a/.github/workflows/update_parent_repos.yml b/.github/workflows/update_parent_repos.yml new file mode 100644 index 00000000..96f66020 --- /dev/null +++ b/.github/workflows/update_parent_repos.yml @@ -0,0 +1,52 @@ +name: Update Submodules in Parent Repos + +on: + pull_request: + types: [closed] + +jobs: + update-submodules: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + strategy: + matrix: + parent-repo: [${{ secrets.PARENT_REPOS }}] + + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + ref: master + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Extract Repo Name + id: extract-repo-name + run: echo "::set-output name=repo_name::$(basename $GITHUB_REPOSITORY)" + + - name: Clone Parent Repo + run: | + git clone ${{ matrix.parent-repo }} parent-repo + cd parent-repo + git submodule update --init --recursive + + - name: Update Submodule + run: | + cd parent-repo + git submodule update --remote path/to/submodule + git add path/to/submodule + git commit -m "Update submodule to latest commit from ${{ steps.extract-repo-name.outputs.repo_name }}" + git push origin master + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GH_PAT }} + commit-message: Update submodule to latest commit from ${{ steps.extract-repo-name.outputs.repo_name }} + branch: update-submodule + title: Update submodule to latest commit from ${{ steps.extract-repo-name.outputs.repo_name }} + body: This PR updates the submodule to the latest commit from ${{ steps.extract-repo-name.outputs.repo_name }}. + base: master From 6f338080f1621ab50d7cc96f0a440444bba8996e Mon Sep 17 00:00:00 2001 From: Parth Aggarwal Date: Fri, 22 Nov 2024 16:37:02 -0800 Subject: [PATCH 2/3] Update update_parent_repos.yml --- .github/workflows/update_parent_repos.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_parent_repos.yml b/.github/workflows/update_parent_repos.yml index 96f66020..ddf3bbd5 100644 --- a/.github/workflows/update_parent_repos.yml +++ b/.github/workflows/update_parent_repos.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - parent-repo: [${{ secrets.PARENT_REPOS }}] + parent-repo: [repo-a, repo-b] # Placeholder, will be replaced dynamically steps: - name: Checkout Repo @@ -27,6 +27,11 @@ jobs: id: extract-repo-name run: echo "::set-output name=repo_name::$(basename $GITHUB_REPOSITORY)" + - name: Set Parent Repos + id: set-parent-repos + run: | + echo "PARENT_REPOS=$(echo ${{ secrets.PARENT_REPOS }} | tr ',' '\n')" >> $GITHUB_ENV + - name: Clone Parent Repo run: | git clone ${{ matrix.parent-repo }} parent-repo From 29d9a47bfdc59533f92c3fc85d2ab4f9b41cbc56 Mon Sep 17 00:00:00 2001 From: Parth Aggarwal Date: Fri, 22 Nov 2024 16:42:10 -0800 Subject: [PATCH 3/3] Update update_parent_repos.yml --- .github/workflows/update_parent_repos.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/update_parent_repos.yml b/.github/workflows/update_parent_repos.yml index ddf3bbd5..b6174ccd 100644 --- a/.github/workflows/update_parent_repos.yml +++ b/.github/workflows/update_parent_repos.yml @@ -1,18 +1,29 @@ name: Update Submodules in Parent Repos on: + workflow_dispatch: pull_request: types: [closed] jobs: update-submodules: - if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest strategy: matrix: - parent-repo: [repo-a, repo-b] # Placeholder, will be replaced dynamically + parent-repo: [] steps: + - name: Set Parent Repos + id: set-parent-repos + run: | + echo "PARENT_REPOS=$(echo ${{ secrets.PARENT_REPOS }} | tr ',' '\n')" >> $GITHUB_ENV + + - name: Set Matrix + id: set-matrix + run: | + echo "::set-output name=matrix::$(echo $PARENT_REPOS | jq -R -s -c 'split("\n") | map(select(length > 0))')" + - name: Checkout Repo uses: actions/checkout@v2 with: @@ -27,11 +38,6 @@ jobs: id: extract-repo-name run: echo "::set-output name=repo_name::$(basename $GITHUB_REPOSITORY)" - - name: Set Parent Repos - id: set-parent-repos - run: | - echo "PARENT_REPOS=$(echo ${{ secrets.PARENT_REPOS }} | tr ',' '\n')" >> $GITHUB_ENV - - name: Clone Parent Repo run: | git clone ${{ matrix.parent-repo }} parent-repo