fix(ci): always use token owner login for gitea auth
This commit is contained in:
parent
e0ba1deaf9
commit
c87d96e6be
1 changed files with 5 additions and 4 deletions
9
.github/workflows/sync-to-gitea.yml
vendored
9
.github/workflows/sync-to-gitea.yml
vendored
|
|
@ -29,21 +29,22 @@ jobs:
|
||||||
- name: Sync to Gitea
|
- name: Sync to Gitea
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_SECRET }}
|
GITEA_TOKEN: ${{ secrets.GITEA_SECRET }}
|
||||||
GITEA_USERNAME: ${{ secrets.GITEA_USERNAME }}
|
|
||||||
REPO: ${{ github.event.repository.name }}
|
REPO: ${{ github.event.repository.name }}
|
||||||
BRANCH: ${{ github.ref_name }}
|
BRANCH: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
test -n "${GITEA_TOKEN:-}" || (echo "GITEA_TOKEN is empty" && exit 1)
|
test -n "${GITEA_TOKEN:-}" || (echo "GITEA_TOKEN is empty" && exit 1)
|
||||||
test -n "${GITEA_USERNAME:-}" || (echo "GITEA_USERNAME is empty" && exit 1)
|
|
||||||
|
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
TARGET_URL="https://${GITEA_USERNAME}:${GITEA_TOKEN}@ci.nxtgauge.com/Admin/${REPO}.git"
|
GITEA_USER="$(curl -fsS -H "Authorization: token ${GITEA_TOKEN}" https://ci.nxtgauge.com/api/v1/user | jq -r '.login')"
|
||||||
|
test -n "${GITEA_USER:-}" || (echo "Unable to resolve Gitea token user" && exit 1)
|
||||||
|
|
||||||
echo "Using Gitea user: ${GITEA_USERNAME}"
|
TARGET_URL="https://${GITEA_USER}:${GITEA_TOKEN}@ci.nxtgauge.com/Admin/${REPO}.git"
|
||||||
|
|
||||||
|
echo "Using Gitea user: ${GITEA_USER}"
|
||||||
echo "Sync target: Admin/${REPO}.git"
|
echo "Sync target: Admin/${REPO}.git"
|
||||||
|
|
||||||
git ls-remote "${TARGET_URL}" >/dev/null
|
git ls-remote "${TARGET_URL}" >/dev/null
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue