Skip to content

Commit

Permalink
added push-to-stable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thoschr committed Apr 6, 2023
1 parent f5807f7 commit 56815e8
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/push-to-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# @author jphaupt
name: Push changes to a public repository

on:
push:
branches:
- stable # branch on private that triggers action

# edit these environment variables if you wish to use in a new project
# note this depends on a separate workflow called build_and_test to exist
# (this job does not run unless build_and_test is successful)
env:
BOT_TOKEN: ${{ secrets.PRIVATE_TO_PUBLIC_PAT }} # PAT for jph-bot
TARGET_REPO: e-cojl
TARGET_BRANCH: main
SOURCE_REPO: e-cojl-devel
SOURCE_BRANCH: stable

jobs:
push-changes:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
ref: stable # unfortunately, cannot use env here, must change manually as well
fetch-depth: 0

- name: clone $SOURCE_BRANCH repo
run: |
git clone https://fkfest:[email protected]/fkfest/$TARGET_REPO.git
cd $TARGET_REPO
git checkout -b auto/from-devel-repo
git config user.name "actions-user"
git config user.email "[email protected]"
- name: pull changes into local copy of public repo from private repo
run: |
cd $TARGET_REPO
git remote add source https://fkfest:[email protected]/fkfest/$SOURCE_REPO
git fetch source $SOURCE_BRANCH
- name: merge changes in public repo
run: |
cd $TARGET_REPO
git merge source/$SOURCE_BRANCH --no-edit
- name: publish new branch
run: |
cd $TARGET_REPO
git push -u origin auto/from-devel-repo
- name: Create Pull Request
run: |
cd $TARGET_REPO
PR_TITLE="Merge changes from development repository"
PR_BODY="This pull request merges changes from the private development repository and was automatically generated by GitHub Actions."
PR_HEAD="auto/from-devel-repo" # branch with changes
PR_BASE="$TARGET_BRANCH"
PR_API_URL=$(curl --silent --request POST --url https://api.github.com/repos/fkfest/$TARGET_REPO/pulls \
--header "authorization: Bearer $BOT_TOKEN" \
--header "content-type: application/json" \
--data "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$PR_HEAD\",\"base\":\"$PR_BASE\"}" \
--write-out '%{url_effective}' \
--output /dev/null)
PR_NUMBER=$(echo $PR_API_URL | cut -d / -f 8)
echo "Pull Request #$PR_NUMBER created."

0 comments on commit 56815e8

Please sign in to comment.