Skip to content

Commit 0a9c542

Browse files
committed
Updating the upstream module hash on push
1 parent 0cdb099 commit 0a9c542

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

.github/workflows/deploy-main-branches.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Build » Deploy main branches
22

3+
# NOTE: This should *not* run on tags, these are handled in the main repo
34
on:
45
push:
56
branches:
@@ -33,6 +34,7 @@ jobs:
3334
#Strip the r/ prefix, giving us just 17.x. If this is main/develop this does nothing
3435
echo "branch=${TEMP#r\/}" >> $GITHUB_OUTPUT
3536
37+
3638
deploy-main-branches:
3739
runs-on: ubuntu-latest
3840
needs: detect-repo-owner
@@ -91,6 +93,59 @@ jobs:
9193
git add assets
9294
git diff --staged --quiet || git commit --amend -m "Build $(date)"
9395
94-
9596
- name: Push updates
9697
run: git push origin gh-pages --force
98+
99+
100+
file-upstream-admin-pr:
101+
name: Create upstream admin PR to incorporate build
102+
runs-on: ubuntu-latest
103+
needs: detect-repo-owner
104+
permissions:
105+
contents: write # For the release
106+
pull-requests: write # For the PR in the upstream repo
107+
108+
steps:
109+
- name: Prepare git
110+
run: |
111+
git config --global user.name "Admin Interface Commit Bot"
112+
git config --global user.email "cloud@opencast.org"
113+
114+
- name: Prepare GitHub SSH key
115+
env:
116+
DEPLOY_KEY: ${{ secrets.MODULE_PR_DEPLOY_KEY }}
117+
run: |
118+
install -dm 700 ~/.ssh/
119+
echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519
120+
chmod 600 ~/.ssh/id_ed25519
121+
ssh-keyscan github.com >> ~/.ssh/known_hosts
122+
123+
- name: Clone upstream repository
124+
run: |
125+
git clone -b ${{ github.ref_name }} "git@github.com:${{ github.repository_owner }}/opencast.git" opencast
126+
cd opencast
127+
git checkout -b t/admin-$GITHUB_REF
128+
129+
- name: Update the admin submodule
130+
working-directory: opencast
131+
run: |
132+
# Note: This could be a race condition in that rapid submodule pushes can trigger multiple PRs in short order
133+
# and we don't have a guarantee that the update triggered by commit A does not end up finding commit B
134+
# We are going to ignore this possibility since we almost universally want the *latest* commit, though this
135+
# could end up causing the commit message, and the actual submodule hash to differ.
136+
git submodule update --init --remote modules/admin-ui
137+
git add modules/admin-ui
138+
git commit -m "Updating admin-service to $GITHUB_REF"
139+
git push origin t/admin-$GITHUB_REF
140+
# This token is an account wide token which allows creation of PRs and pushes.
141+
echo "${{ secrets.MODULE_PR_TOKEN }}" > token.txt
142+
gh auth login --with-token < token.txt
143+
gh pr create \
144+
--title "Update ${{ needs.detect-repo-owner.outputs.branch }} Admin Interface to $GITHUB_REF" \
145+
--body "Updating Opencast ${{ needs.detect-repo-owner.outputs.branch }} Admin Interface module to [$GITHUB_REF](https://github.com/${{ github.repository_owner }}/admin-interface/commit/$GITHUB_REF)" \
146+
--head=${{ github.repository_owner }}:t/admin-$GITHUB_REF \
147+
--base ${{ github.ref_name }} \
148+
-R ${{ github.repository_owner }}/opencast
149+
#FIXME: fine grained PATs can't apply labels
150+
#FIXME: classic PATs don't have the permissions because the PR isn't in an opencastproject (the user) repo
151+
#--label admin-ui --label maintenance \

0 commit comments

Comments
 (0)