mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
chore: cascade forgejo pull request out of the runner branch or PR
Refs forgejo/runner#881
This commit is contained in:
parent
ea5085ae9d
commit
45251acf1f
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