mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 18:33:13 +03:00
github: submodules-update: Port in all the releasehub code & tweak
We want to *check* if there are any changes and only make a branch and add commits if so. The upstream code has no option for this, so use it as a starting point instead. Specifically this is based on: https://github.com/releasehub-com/github-action-create-pr-parent-submodule/blob/main/action.yml aff9d0978a9bbcbc2961d621d5b108c4b46db5e7 * We need 'success' from the *step* to be when there ARE changes, and that is in the special github output. * In order for the whole job *not* to fail in the 'step check_for_changes says it failed' case we need it to have `continue-on-error: true`.
This commit is contained in:
parent
3a82965329
commit
6963a24728
82
.github/workflows/submodule-update.yml
vendored
82
.github/workflows/submodule-update.yml
vendored
@ -6,9 +6,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
|
|
||||||
###############
|
|
||||||
# Set the Job #
|
|
||||||
###############
|
|
||||||
jobs:
|
jobs:
|
||||||
check_submodules:
|
check_submodules:
|
||||||
name: Pull Request for updated submodules
|
name: Pull Request for updated submodules
|
||||||
@ -20,21 +17,66 @@ jobs:
|
|||||||
OWNER: 'EDCD'
|
OWNER: 'EDCD'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
##########################
|
- uses: actions/checkout@v2.4.0
|
||||||
# Checkout the code base #
|
|
||||||
##########################
|
|
||||||
- name: Checkout EDMC
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
####################################
|
|
||||||
# Run the action against code base #
|
|
||||||
####################################
|
|
||||||
- name: Check EDMC submodules
|
|
||||||
id: run_action
|
|
||||||
uses: releasehub-com/github-action-create-pr-parent-submodule@v1
|
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
submodules: true
|
||||||
parent_repository: ${{ env.PARENT_REPOSITORY }}
|
|
||||||
checkout_branch: ${{ env.CHECKOUT_BRANCH}}
|
- name: Update submodules
|
||||||
pr_against_branch: ${{ env.PR_AGAINST_BRANCH }}
|
shell: bash
|
||||||
owner: ${{ env.OWNER }}
|
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@v5
|
||||||
|
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@v5
|
||||||
|
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 }}']
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user