ci: authenticate artifactapi upload with a vault token #10
@@ -58,10 +58,17 @@ steps:
|
||||
echo "$$PATH_IN_REPO already published (HTTP $$code); skipping upload"
|
||||
exit 0
|
||||
fi
|
||||
set -o pipefail
|
||||
VAULT="https://vault.service.consul:8200"
|
||||
AUTH=$$(mktemp)
|
||||
VT=$$(jq -n --rawfile jwt /var/run/secrets/kubernetes.io/serviceaccount/token '{role:"woodpecker_artifactapi_writer",jwt:$$jwt}' \
|
||||
| curl -sf -d @- "$$VAULT/v1/auth/k8s/au/syd1/login" | jq -er .auth.client_token) || exit 1
|
||||
printf 'X-Vault-Token: %s\n' "$$VT" | curl -sf -H @- "$$VAULT/v1/identity/oidc/token/artifactapi-writer" \
|
||||
| jq -er '"Authorization: Bearer " + .data.token' > "$$AUTH" || exit 1
|
||||
echo "Uploading $$ZIP to $$REPO/$$PATH_IN_REPO (existence probe returned $$code)"
|
||||
curl -f -X PUT \
|
||||
"$$HOST/api/v2/remotes/$$REPO/files/$$PATH_IN_REPO" \
|
||||
-H "Content-Type: application/zip" \
|
||||
-H "Content-Type: application/zip" -H @"$$AUTH" \
|
||||
--data-binary @"$$ZIP"
|
||||
depends_on: [package]
|
||||
backend_options:
|
||||
|
||||
Reference in New Issue
Block a user