1
0
Fork 0
mirror of https://code.forgejo.org/actions/cascading-pr synced 2025-03-15 14:54:40 +01:00

create the repositories, tokens and secrets

This commit is contained in:
Earl Warren 2023-10-11 22:32:24 +02:00
parent cdd3f46d7b
commit 2892041d6c
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 40 additions and 4 deletions

3
tests/destinationrepo/upgraded Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo upgrade done

View file

@ -0,0 +1,18 @@
# SPDX-License-Identifier: MIT
name: test
on: [pull_request]
jobs:
test:
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: SELF@vTest
with:
origin-url: ${{ env.$GITHUB_SERVER_URL }}
origin-repo: user1/originrepo
origin-token: ${{ secrets.ORIGIN_TOKEN }}
destination-url: ${{ env.$GITHUB_SERVER_URL }}
destination-repo: user2/destinationrepo
destination-token: ${{ secrets.DESTINATION_TOKEN }}
update: upgraded
debug: true

View file

@ -31,7 +31,19 @@ function user_curl() {
) )
} }
function create_user() { function user_token() {
local username=$1 name=$2
curl -sS -f -H Content-Type:application/json --user "$username:${options[password]}" --data-raw '{"name":"'$name'","scopes":["write:repository","write:issue"]}' ${options[url]}/api/v1/users/$username/tokens | jq --raw-output .sha1
}
function user_secret() {
local username=$1 name=$2 token=$3
user_curl $username api_json -X PUT --data-raw '{"data":"'$token'"}' ${options[url]}/api/v1/repos/user1/originrepo/actions/secrets/$name
}
function user_create() {
local username="$1" email="$2" local username="$1" email="$2"
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/admin/users/$username?purge=true >& /dev/null || true forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/admin/users/$username?purge=true >& /dev/null || true
forgejo-curl.sh api_json --data-raw '{"username":"'$username'","email":"'$email'","password":"'${options[password]}'","must_change_password":false}' ${options[url]}/api/v1/admin/users forgejo-curl.sh api_json --data-raw '{"username":"'$username'","email":"'$email'","password":"'${options[password]}'","must_change_password":false}' ${options[url]}/api/v1/admin/users
@ -39,10 +51,13 @@ function create_user() {
} }
function run() { function run() {
create_user user1 user1@example.com user_create user2 user2@example.com
forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr forgejo-test-helper.sh push tests/destinationrepo http://user2:admin1234@${options[host_port]} user2 destinationrepo
create_user user2 user2@example.com user_create user1 user1@example.com
forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr
user_secret user1 ORIGIN_TOKEN $(user_token user1 ORIGIN_TOKEN)
user_secret user1 DESTINATION_TOKEN $(user_token user2 DESTINATION_TOKEN)
push_self ${options[host_port]} push_self ${options[host_port]}