Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/update_parent_repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Update Submodules in Parent Repos

on:
workflow_dispatch:
pull_request:
types: [closed]

jobs:
update-submodules:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
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:
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