mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-05 18:40:59 +00:00
chore: cascade forgejo pull request out of the runner branch or PR (#883)
Refs forgejo/runner#881 --- This was tested manually to work but cannot be tested automatically. It is archived in this pull request for the record rather than for review. Testing will continue after it is merged, to verify it does what it should for pull requests and not just for branches. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - other - [PR](https://code.forgejo.org/forgejo/runner/pulls/883): <!--number 883 --><!--line 0 --><!--description Y2hvcmU6IGNhc2NhZGUgZm9yZ2VqbyBwdWxsIHJlcXVlc3Qgb3V0IG9mIHRoZSBydW5uZXIgYnJhbmNoIG9yIFBS-->chore: cascade forgejo pull request out of the runner branch or PR<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/883 Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
34731a41be
commit
07fadb3461
2 changed files with 125 additions and 0 deletions
37
.forgejo/cascading-forgejo
Executable file
37
.forgejo/cascading-forgejo
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
forgejo=$1
|
||||||
|
forgejo_pr=$2
|
||||||
|
runner=$3
|
||||||
|
runner_pr_or_ref=$4
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get information from the runner
|
||||||
|
#
|
||||||
|
cd $runner
|
||||||
|
#
|
||||||
|
# code.forgejo.org/forgejo/runner/vN may be
|
||||||
|
# upgraded to code.forgejo.org/forgejo/runner/vN+1
|
||||||
|
#
|
||||||
|
module=$(cat go.mod | head -1 | cut -d' ' -f2)
|
||||||
|
test "$module"
|
||||||
|
sha=$(git -C $runner show --no-patch --format=%H)
|
||||||
|
test "$sha"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Update Forgejo to use the runner at $runner_pr_or_ref
|
||||||
|
#
|
||||||
|
cd $forgejo
|
||||||
|
#
|
||||||
|
# Update the runner major version if needed
|
||||||
|
#
|
||||||
|
find * -name '*.go' -o -name 'go.mod' | xargs sed -i -E -e "s|code.forgejo.org/forgejo/runner/v[0-9]+|$module|"
|
||||||
|
#
|
||||||
|
# add a "replace code.forgejo.org/forgejo/runner/v?? $sha" line to the forgejo go.mod
|
||||||
|
# so that it uses the branch or pull request from which the cascade is run.
|
||||||
|
#
|
||||||
|
sed -i -e "\|replace $module|d" go.mod
|
||||||
|
echo "replace $module => $module $sha" >>go.mod
|
||||||
|
go mod tidy
|
88
.forgejo/workflows/cascade-forgejo.yml
Normal file
88
.forgejo/workflows/cascade-forgejo.yml
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
# Copyright 2025 The Forgejo Authors
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
# FORGEJO_CASCADING_PR_ORIGIN_TOKEN is a token from the https://code.forgejo.org/cascading-pr user
|
||||||
|
# with scope write:issue read:repository read:user
|
||||||
|
# FORGEJO_CASCADING_PR_DESTINATION_TOKEN is a token from the https://codeberg.org/forgejo-cascading-pr user
|
||||||
|
# with scope write:issue write:repository read:user
|
||||||
|
#
|
||||||
|
# To modify this workflow:
|
||||||
|
#
|
||||||
|
# - push it to the wip-cascade branch on the repository
|
||||||
|
# otherwise it will not have access to the secrets required to push
|
||||||
|
# the cascading PR
|
||||||
|
#
|
||||||
|
# - once it works, open a pull request for the sake of keeping track
|
||||||
|
# of the change even if the PR won't run it because it will use
|
||||||
|
# whatever is in the default branch instead
|
||||||
|
#
|
||||||
|
# - after it is merged, double check it works by setting the
|
||||||
|
# label on a pull request (any pull request will do)
|
||||||
|
#
|
||||||
|
name: cascade
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
- 'wip-cascade'
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- synchronize
|
||||||
|
- labeled
|
||||||
|
|
||||||
|
enable-email-notifications: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
debug:
|
||||||
|
if: >
|
||||||
|
vars.DEBUG == 'yes'
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: data.forgejo.org/oci/node:22-bookworm
|
||||||
|
steps:
|
||||||
|
- name: event
|
||||||
|
run: |
|
||||||
|
cat <<'EOF'
|
||||||
|
${{ toJSON(forge.event.pull_request.labels.*.name) }}
|
||||||
|
EOF
|
||||||
|
cat <<'EOF'
|
||||||
|
${{ toJSON(forge.event) }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
forgejo:
|
||||||
|
if: >
|
||||||
|
vars.ROLE == 'forgejo-coding' && (
|
||||||
|
forge.ref_name == 'main' ||
|
||||||
|
forge.ref_name == 'wip-cascade' ||
|
||||||
|
contains(github.event.pull_request.labels.*.name, 'run-forgejo-tests')
|
||||||
|
)
|
||||||
|
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: data.forgejo.org/oci/node:22-bookworm
|
||||||
|
steps:
|
||||||
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: '0'
|
||||||
|
show-progress: 'false'
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
- uses: https://data.forgejo.org/actions/cascading-pr@v2.2.1
|
||||||
|
with:
|
||||||
|
origin-url: ${{ forge.server_url }}
|
||||||
|
origin-repo: ${{ forge.repository }}
|
||||||
|
origin-token: ${{ secrets.FORGEJO_CASCADING_PR_ORIGIN_TOKEN }}
|
||||||
|
origin-pr: ${{ forge.event.pull_request.number }}
|
||||||
|
origin-ref: ${{ forge.event_name == 'push' && forge.event.ref || '' }}
|
||||||
|
destination-url: https://codeberg.org
|
||||||
|
destination-fork-repo: forgejo-cascading-pr/forgejo
|
||||||
|
destination-repo: forgejo/forgejo
|
||||||
|
destination-branch: forgejo
|
||||||
|
destination-token: ${{ secrets.FORGEJO_CASCADING_PR_DESTINATION_TOKEN }}
|
||||||
|
prefix: runner
|
||||||
|
close-merge: true
|
||||||
|
verbose: ${{ vars.VERBOSE == 'yes' }}
|
||||||
|
debug: ${{ vars.DEBUG == 'yes' }}
|
||||||
|
update: .forgejo/cascading-forgejo
|
Loading…
Add table
Add a link
Reference in a new issue