-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (60 loc) · 2.43 KB
/
push-to-stable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# @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
ORGA_NAME: fkfest
TARGET_REPO: ElemCo.jl
TARGET_BRANCH: main
SOURCE_REPO: ElemCo.jl-devel
SOURCE_BRANCH: stable
jobs:
push-changes:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.SOURCE_BRANCH }}
fetch-depth: 0
- name: clone $SOURCE_BRANCH repo
run: |
git clone https://$ORGA_NAME:[email protected]/$ORGA_NAME/$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://$ORGA_NAME:[email protected]/$ORGA_NAME/$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/$ORGA_NAME/$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."