Files
EDMarketConnector/.github/workflows/submodule-update.yml
T
dependabot[bot] 4ea1609f36 build(deps): bump actions/checkout from 2.4.0 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 17:04:05 +00:00

83 lines
2.7 KiB
YAML

---
name: Submodule Updates
on:
# We might want this on a schedule once this is in `main`
push:
branches: [ develop ]
jobs:
check_submodules:
name: Pull Request for updated submodules
runs-on: ubuntu-latest
env:
PARENT_REPOSITORY: 'EDCD/EDMarketConnector'
CHECKOUT_BRANCH: 'develop'
PR_AGAINST_BRANCH: 'develop'
OWNER: 'EDCD'
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Update submodules
shell: bash
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git submodule update --remote
- name: Check for changes
id: check_for_changes
continue-on-error: true
run: |
changes=$(git status --porcelain)
if [ -n "${changes}" ];
then
echo '::set-output changes=true'
fi
echo '::set-output changes=false'
exit 0
- name: Create submodules changes branch
if: steps.check_for_changes.outputs.changes == 'true'
run: |
git checkout -b $GITHUB_RUN_ID
git commit -am "updating submodules"
git push --set-upstream origin $GITHUB_RUN_ID
- name: Create pull request against target branch
if: steps.check_for_changes.outputs.changes == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github_token }}
script: |
await github.rest.pulls.create({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
head: process.env.GITHUB_RUN_ID,
base: '${{ inputs.pr_against_branch }}',
title: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
body: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
});
- name: Add labels
if: steps.check_for_changes.outputs.changes == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ inputs.github_token }}
script: |
const res = await github.rest.issues.listForRepo({
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
});
const pr = res.data.filter(i => i.title.includes(process.env.GITHUB_RUN_ID));
const prNumber = pr[0].number;
await github.rest.issues.addLabels({
issue_number: prNumber,
owner: '${{ inputs.owner }}',
repo: '${{ inputs.parent_repository }}'.split('/')[1].trim(),
labels: ['${{ inputs.label }}']
});