diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f72d0d9107..c64cdcbf6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -489,6 +489,17 @@ jobs: sleep 15 done + - name: Provision Gitea + if: matrix.service.name == 'VCSGitea' + timeout-minutes: 5 + run: | + docker compose up -d --wait gitea gitea-bootstrap + CREDS=$(docker compose exec -T gitea cat /data/gitea/oauth.json) + CLIENT_SECRET=$(echo "$CREDS" | jq -r .client_secret) + echo "::add-mask::$CLIENT_SECRET" + echo "_APP_VCS_GITEA_CLIENT_ID=$(echo "$CREDS" | jq -r .client_id)" >> $GITHUB_ENV + echo "_APP_VCS_GITEA_CLIENT_SECRET=$CLIENT_SECRET" >> $GITHUB_ENV + - name: Load and Start Appwrite timeout-minutes: 5 env: diff --git a/dev/gitea/setup.sh b/dev/gitea/setup.sh new file mode 100755 index 0000000000..204737861c --- /dev/null +++ b/dev/gitea/setup.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu + +su git -c "gitea admin user create --username $GITEA_ADMIN_USERNAME --password $GITEA_ADMIN_PASSWORD --email $GITEA_ADMIN_EMAIL --admin --must-change-password=false" || true + +if [ ! -f /data/gitea/oauth.json ]; then + curl -sf -X POST -u "$GITEA_ADMIN_USERNAME:$GITEA_ADMIN_PASSWORD" \ + -H 'Content-Type: application/json' \ + -d '{"name":"Appwrite","redirect_uris":["http://localhost/v1/vcs/gitea/callback"],"confidential_client":true}' \ + http://gitea:3000/api/v1/user/applications/oauth2 > /tmp/oauth.json + mv /tmp/oauth.json /data/gitea/oauth.json +fi diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 3c14bea4c6..069296956b 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -382,6 +382,7 @@ services: - appwrite volumes: - appwrite-gitea:/data + - ./dev/gitea/setup.sh:/setup.sh:ro depends_on: gitea: condition: service_healthy @@ -390,10 +391,7 @@ services: - GITEA_ADMIN_PASSWORD=${GITEA_ADMIN_PASSWORD:-password} - GITEA_ADMIN_EMAIL=${GITEA_ADMIN_EMAIL:-gitea@appwrite.io} entrypoint: /bin/sh - command: > - -c " - su git -c \"gitea admin user create --username $$GITEA_ADMIN_USERNAME --password $$GITEA_ADMIN_PASSWORD --email $$GITEA_ADMIN_EMAIL --admin --must-change-password=false\" || true - " + command: /setup.sh appwrite-mongo-express: profiles: - mongodb