From 89ed6c518641e89925192e786d73706a61300252 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 5 Apr 2023 17:40:06 +0200 Subject: [PATCH] Forgejo >= v1.19.0-3 needs repo.actions Fixes: https://code.forgejo.org/actions/setup-forgejo/issues/3 --- .forgejo/workflows/forgejo-sh.yml | 21 +++++++++++++++++++++ .forgejo/workflows/integration.yml | 2 +- action.yml | 2 +- forgejo-dependencies.sh | 2 +- forgejo.sh | 17 ++++++++++++----- 5 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 .forgejo/workflows/forgejo-sh.yml diff --git a/.forgejo/workflows/forgejo-sh.yml b/.forgejo/workflows/forgejo-sh.yml new file mode 100644 index 0000000..3d0b818 --- /dev/null +++ b/.forgejo/workflows/forgejo-sh.yml @@ -0,0 +1,21 @@ +on: + push: + paths: + - forgejo.sh + pull_request: + paths: + - forgejo.sh + +jobs: + forgejo-sh: + runs-on: self-hosted + steps: + - uses: actions/checkout@v3 + - run: | + set -x + ./forgejo-dependencies.sh install_docker + for version in 1.19.0-2 1.19.0-3; do + echo "=========================== launching forgejo v$version ==========" + ./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo $version + ./forgejo.sh teardown + done diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index 3246eef..fc0e253 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -7,7 +7,7 @@ jobs: - run: | set -x LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh - ./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19 + ./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.19 # # Uncomment the following for a shortcut to debugging the Forgejo runner. # It will build the runner from a designated repository and branch instead of diff --git a/action.yml b/action.yml index a5fb603..6810c79 100644 --- a/action.yml +++ b/action.yml @@ -80,7 +80,7 @@ runs: cd $(mktemp -d) LXC_IP_PREFIX=${{ inputs.lxc-ip-prefix }} forgejo-dependencies.sh export CONTAINER=${{ inputs.container }} - forgejo.sh setup ${{ inputs.user }} "${{ inputs.password }}" ${{ inputs.image }}:${{ inputs.image-version }} + forgejo.sh setup ${{ inputs.user }} "${{ inputs.password }}" ${{ inputs.image }} ${{ inputs.image-version }} forgejo-runner.sh setup ${{ inputs.runner }} ${{ inputs.runner-version }} http://$(cat forgejo-ip):3000/ echo url="http://$(cat forgejo-ip):3000" >> $GITHUB_OUTPUT echo host-port="$(cat forgejo-ip):3000" >> $GITHUB_OUTPUT diff --git a/forgejo-dependencies.sh b/forgejo-dependencies.sh index 3a9d606..42ee283 100755 --- a/forgejo-dependencies.sh +++ b/forgejo-dependencies.sh @@ -43,4 +43,4 @@ function setup() { install_lxc } -setup +"${@:-setup}" diff --git a/forgejo.sh b/forgejo.sh index 7c55717..173d553 100755 --- a/forgejo.sh +++ b/forgejo.sh @@ -4,7 +4,6 @@ set -e if ${VERBOSE:-false}; then set -x; fi - : ${CONTAINER:=forgejo} function wait_for() { @@ -27,6 +26,13 @@ function wait_for() { function run() { local image="$1" + local version="$2" + + if dpkg --compare-versions "$version" "lt" "1.19.0-3"; then + actions_unit="actions.actions" + else + actions_unit="repo.actions" + fi docker run --restart unless-stopped --name ${CONTAINER} \ -e "RUN_MODE=dev" \ @@ -35,8 +41,8 @@ function run() { -e "FORGEJO__actions__ENABLED=true" \ -e "FORGEJO__repository__ENABLE_PUSH_CREATE_USER=true" \ -e "FORGEJO__repository__DEFAULT_PUSH_CREATE_PRIVATE=false" \ - -e "FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,actions.actions" \ - -d $image + -e "FORGEJO__repository__DEFAULT_REPO_UNITS=repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,$actions_unit" \ + -d $image:$version local ip="$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" ${CONTAINER})" echo $ip > forgejo-ip docker exec ${CONTAINER} sed -i -e "s|localhost|$ip|" /data/gitea/conf/app.ini @@ -46,9 +52,10 @@ function run() { function setup() { local user="${1:-root}" local password="${2:-admin1234}" - local image="${3:-codeberg.org/forgejo/forgejo:1.19}" + local image="${3:-codeberg.org/forgejo/forgejo}" + local version="${4:-1.19}" - run $image + run $image $version sleep 5 # for some reason trying to run "forgejo admin" while forgejo is booting will permanently break everything if docker exec --user 1000 ${CONTAINER} forgejo admin user list --admin | grep "$user" ; then