mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-02 16:41:04 +03:00
#1443 Update GitHub Workflow Submodules
This commit is contained in:
parent
db73b9d775
commit
b75b6be23f
40
.github/workflows/submodule-update.yml
vendored
40
.github/workflows/submodule-update.yml
vendored
@ -1,11 +1,10 @@
|
|||||||
---
|
|
||||||
name: Submodule Updates
|
name: Submodule Updates
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ develop ]
|
branches: [develop]
|
||||||
# schedule:
|
schedule:
|
||||||
# - cron: '0 12 * * *'
|
- cron: '0 12 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check_submodules:
|
check_submodules:
|
||||||
@ -44,25 +43,44 @@ jobs:
|
|||||||
echo 'changes=false' >> $GITHUB_OUTPUT
|
echo 'changes=false' >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
- name: Create submodules changes branch
|
- name: Create or Update submodules changes branch
|
||||||
if: steps.check_for_changes.outputs.changes == 'true'
|
if: steps.check_for_changes.outputs.changes == 'true'
|
||||||
run: |
|
run: |
|
||||||
git checkout -b "submodule-change/$GITHUB_RUN_ID" $CHECKOUT_BRANCH
|
git fetch origin "submodule-change/$GITHUB_RUN_ID" || git checkout -b "submodule-change/$GITHUB_RUN_ID" $CHECKOUT_BRANCH
|
||||||
git commit -am "updating submodules"
|
git commit -am "updating submodules"
|
||||||
git push --set-upstream origin "submodule-change/$GITHUB_RUN_ID"
|
git push --set-upstream origin "submodule-change/$GITHUB_RUN_ID"
|
||||||
|
|
||||||
- name: Create pull request against target branch
|
- name: Create or Update pull request against target branch
|
||||||
if: steps.check_for_changes.outputs.changes == 'true'
|
if: steps.check_for_changes.outputs.changes == 'true'
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
script: |
|
script: |
|
||||||
await github.rest.pulls.create({
|
const { data: pulls } = await github.rest.pulls.list({
|
||||||
owner: '${{ github.repository_owner }}',
|
owner: '${{ github.repository_owner }}',
|
||||||
repo: '${{ github.repository }}'.split('/')[1].trim(),
|
repo: '${{ github.repository }}'.split('/')[1].trim(),
|
||||||
head: 'submodule-change/${{ github.run_id }}',
|
head: 'submodule-change/${{ github.run_id }}',
|
||||||
base: '${{ env.PR_AGAINST_BRANCH }}',
|
base: '${{ env.PR_AGAINST_BRANCH }}',
|
||||||
title: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
|
state: 'open',
|
||||||
body: '${{ steps.check_for_changes.outputs.changes_text }}',
|
|
||||||
});
|
});
|
||||||
|
if (pulls.length > 0) {
|
||||||
|
// If an open pull request exists, update it
|
||||||
|
const pull_number = pulls[0].number;
|
||||||
|
await github.rest.pulls.update({
|
||||||
|
owner: '${{ github.repository_owner }}',
|
||||||
|
repo: '${{ github.repository }}'.split('/')[1].trim(),
|
||||||
|
pull_number,
|
||||||
|
body: '${{ steps.check_for_changes.outputs.changes_text }}',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// If no open pull request exists, create a new one
|
||||||
|
await github.rest.pulls.create({
|
||||||
|
owner: '${{ github.repository_owner }}',
|
||||||
|
repo: '${{ github.repository }}'.split('/')[1].trim(),
|
||||||
|
head: 'submodule-change/${{ github.run_id }}',
|
||||||
|
base: '${{ env.PR_AGAINST_BRANCH }}',
|
||||||
|
title: `[Auto-generated] Submodule Updates ${process.env.GITHUB_RUN_ID}`,
|
||||||
|
body: '${{ steps.check_for_changes.outputs.changes_text }}',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user