1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-forgejo synced 2024-09-19 01:46:16 +00:00

do not rely on a hacky way to obtain the sha of the branch

This commit is contained in:
Earl Warren 2023-10-07 23:27:24 +02:00
parent 179856df25
commit 7b5b59d821
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 15 additions and 8 deletions

View file

@ -31,10 +31,11 @@ jobs:
#
forgejo-runner.sh setup
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
url=http://root:admin1234@$(cat forgejo-ip):3000
token=$(cat forgejo-token)
echo "============================ demo ==================="
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output
grep '^sha=' /tmp/output
forgejo-test-helper.sh run_workflow testdata/demo $url root demo setup-forgejo $token
function run() {
local example=$1
@ -51,7 +52,7 @@ jobs:
echo "============================ RUN example-$example ==================="
bash -ex $EXAMPLE_DIR/run.sh || return 1
else
forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) || return 1
forgejo-test-helper.sh run_workflow testdata/example-$example $url root example-$example setup-forgejo $token || return 1
fi
if test -f $EXAMPLE_DIR/teardown.sh ; then

View file

@ -20,8 +20,7 @@ The forgejo-test-helper.sh script is available to help test and debug actions.
`testrepo/.forgejo/workflows/*.yml` are replaced with `$forgejo/root/myaction`.
* `forgejo-test-helper.sh push testrepo $forgejo root testrepo`
Creates the repository `$forgejo/root/testrepo` and populates it with the
content of the `testrepo` directory. The SHA of the tip of the repository
is in the output, on a line starting with `sha=`.
content of the `testrepo` directory.
* `forgejo-test-helper.sh build_runner $forgejo/forgejo/runner v3.0.1`
Builds the forgejo runner from source in `./forgejo-runner/forgejo-runner`.
`export PATH=$(pwd)/forgejo-runner:$PATH` will ensure that calling `forgejo-runner.sh`

View file

@ -19,8 +19,7 @@ description: |
`testrepo/.forgejo/workflows/*.yml` are replaced with `$forgejo/root/myaction`.
* `forgejo-test-helper.sh push testrepo $forgejo root testrepo`
Creates the repository `$forgejo/root/testrepo` and populates it with the
content of the `testrepo` directory. The SHA of the tip of the repository
is in the output, on a line starting with `sha=`.
content of the `testrepo` directory.
* `forgejo-test-helper.sh build_runner $forgejo/forgejo/runner v3.0.1`
Builds the forgejo runner from source in `./forgejo-runner/forgejo-runner`.
`export PATH=$(pwd)/forgejo-runner:$PATH` will ensure that calling `forgejo-runner.sh`

View file

@ -44,6 +44,15 @@ function build_runner() {
forgejo-runner --version
}
function branch_tip() {
local url="$1"
local repo="$2"
local branch="$3"
forgejo.sh retry forgejo-curl.sh api_json $url/api/v1/repos/$repo/branches/$branch >& /dev/null
forgejo-curl.sh api_json $url/api/v1/repos/$repo/branches/$branch | jq --raw-output .commit.id
}
function get_status() {
local url="$1"
local repo="$2"
@ -111,7 +120,6 @@ function push() {
git push --force -u origin main
sha=$(git rev-parse HEAD)
echo $sha > SHA
echo sha=$sha
)
}