forked from mirrors/terraform-provider-binarylane
Merge pull request 'ci: authenticate artifactapi provider upload with a vault token' (#5) from benvin/artifactapi-upload-token into main
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -35,9 +35,16 @@ steps:
|
||||
- |
|
||||
VERSION=$$(echo ${CI_COMMIT_TAG} | sed 's/^v//')
|
||||
FILE="terraform-provider-binarylane_$${VERSION}_linux_amd64.zip"
|
||||
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
|
||||
curl -f -X PUT \
|
||||
"https://artifactapi.k8s.syd1.au.unkin.net/api/v2/remotes/terraform-unkin/files/unkin/binarylane/$${FILE}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
-H "Content-Type: application/zip" -H @"$$AUTH" \
|
||||
--data-binary @"$${FILE}"
|
||||
depends_on: [package]
|
||||
backend_options:
|
||||
|
||||
Reference in New Issue
Block a user