-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from UE4SS-RE/FinalizeUESubmAction
Finalize ue submodule github action
- Loading branch information
Showing
1 changed file
with
45 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,66 +2,54 @@ name: Update UE Submodule and Create PR | |
|
||
on: | ||
workflow_dispatch: | ||
|
||
|
||
env: | ||
COMMITS_BODY: '' | ||
|
||
jobs: | ||
update-submodule: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
ssh-key: ${{ secrets.UEPSEUDO_SSH_KEY }} | ||
- name: Setup github SSH for UEPseudo | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.UEPSEUDO_SSH_KEY }} | ||
known_hosts: unnecessary | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Initialize submodule | ||
run: | | ||
git submodule update --init --recursive | ||
- name: Get commits between HEAD and main in the submodule | ||
id: submodule-commits | ||
run: | | ||
cd ./deps/first/Unreal | ||
git fetch origin main | ||
git log HEAD..main --pretty="tformat:* %s (**%an**) _%h_" > submodule-commits.txt | ||
- name: Update submodule to latest commit on main branch | ||
run: | | ||
cd ./deps/first/Unreal | ||
git checkout main | ||
git pull origin main | ||
- name: Create a new branch and commit submodule update | ||
run: | | ||
git checkout -b submodule-update-branch | ||
git add -A | ||
git commit -m "Update UE submodule with the following commits: | ||
$(cat deps/first/Unreal/submodule-commits.txt)" | ||
git push origin submodule-update-branch | ||
create-pr: | ||
needs: update-submodule | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Create Pull Request | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const github = require('@actions/github'); | ||
const octokit = github.getOctokit(process.env.GITHUB_TOKEN); | ||
const context = github.context; | ||
const base = 'main'; // change to the target branch of your choice | ||
const head = `submodule-update-branch`; | ||
const { data: pullRequest } = await octokit.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: 'Update Submodule', | ||
base, | ||
head, | ||
body: 'Updating submodule with recent commits.', | ||
}); | ||
console.log(`Created Pull Request: ${pullRequest.html_url}`); | ||
- name: Initialize submodule | ||
run: | | ||
git submodule update --init --recursive | ||
- name: Get commits between HEAD and main in the submodule | ||
id: submodule-commits | ||
run: | | ||
cd ./deps/first/Unreal | ||
git fetch origin main | ||
git log HEAD..main --pretty="tformat:* %s (**%an**) _%h_" >> submodule-commits.txt | ||
body=$(cat submodule-commits.txt) | ||
body="${body//'%'/'%25'}" | ||
body="${body//$'\n'/'%0A'}" | ||
body="${body//$'\r'/'%0D'}" | ||
echo "COMMITS_BODY=$body" >> $GITHUB_ENV | ||
- name: Update submodule to latest commit on main branch | ||
run: | | ||
cd ./deps/first/Unreal | ||
git checkout main | ||
git pull origin main | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
commit-message: Update UE Submodule | ||
committer: GitHub <[email protected]> | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
title: Update UE Submodule | ||
body: ${{ env.COMMITS_BODY }} | ||
branch: update-ue-submodule | ||
base: main |