Skip to content

Commit

Permalink
Merge pull request #272 from UE4SS-RE/FinalizeUESubmAction
Browse files Browse the repository at this point in the history
Finalize ue submodule github action
  • Loading branch information
narknon committed Nov 2, 2023
2 parents 3dea962 + 8f57f24 commit d5fb1d9
Showing 1 changed file with 45 additions and 57 deletions.
102 changes: 45 additions & 57 deletions .github/workflows/UpdateUESubmodule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d5fb1d9

Please sign in to comment.