diff --git a/.gitea/workflows/package.yml b/.gitea/workflows/package.yml index 931111d..4b0af5a 100644 --- a/.gitea/workflows/package.yml +++ b/.gitea/workflows/package.yml @@ -20,17 +20,32 @@ jobs: with: github-server-url: ${{ github.server_url }} + - name: Normalize image metadata + env: + RAW_REGISTRY_HOST: ${{ vars.REGISTRY_HOST }} + RAW_REPOSITORY: ${{ github.repository }} + IMAGE_TAG: ${{ github.ref_name }} + run: | + REGISTRY_HOST="${RAW_REGISTRY_HOST#http://}" + REGISTRY_HOST="${REGISTRY_HOST#https://}" + REGISTRY_HOST="${REGISTRY_HOST%/}" + REPOSITORY_PATH="${RAW_REPOSITORY#/}" + IMAGE_NAME="${REGISTRY_HOST}/${REPOSITORY_PATH}" + { + echo "REGISTRY_HOST=${REGISTRY_HOST}" + echo "REPOSITORY_PATH=${REPOSITORY_PATH}" + echo "IMAGE_NAME=${IMAGE_NAME}" + echo "IMAGE_TAG=${IMAGE_TAG}" + echo "IMAGE_REF=${IMAGE_NAME}:${IMAGE_TAG}" + } >> "$GITHUB_ENV" + - name: Login to Gitea Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ vars.REGISTRY_HOST }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "$REGISTRY_HOST" \ + --username "${{ secrets.REGISTRY_USERNAME }}" \ + --password-stdin - name: Build and Push Image - env: - IMAGE_NAME: ${{ vars.REGISTRY_HOST }}/${{ github.repository }} - IMAGE_TAG: ${{ github.ref_name }} run: | docker build \ -f ./Dockerfile \ @@ -51,13 +66,11 @@ jobs: - name: Notify Deploy Server if: success() - env: - IMAGE: ${{ vars.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }} run: | curl -fsSL -X POST "${{ vars.DEPLOY_WEBHOOK_URL }}" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${{ secrets.DEPLOY_WEBHOOK_TOKEN }}" \ - -d "{\"image\":\"${IMAGE}\",\"tag\":\"${{ github.ref_name }}\",\"repo\":\"${{ github.repository }}\"}" + -d "{\"image\":\"${IMAGE_REF}\",\"tag\":\"${IMAGE_TAG}\",\"repo\":\"${REPOSITORY_PATH}\"}" deploy-fallback-log: runs-on: ubuntu