Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DOCKER_BUILD_FLAGS ?=
IMAGE_TAG ?= latest

.PHONY: all
all: test bump-readme release
all: test bump-readme release test-oidc

.PHONY: bump-readme
bump-readme:
Expand Down Expand Up @@ -34,6 +34,25 @@ test:
release:
CGO_ENABLED=0 $(GO) build $(GO_BUILD_FLAGS) -mod=vendor -o ./release ./cmd/main.go

.PHONY: test-oidc
test-oidc:
echo "ACTIONS_ID_TOKEN_REQUEST_URL set: $${ACTIONS_ID_TOKEN_REQUEST_URL:+yes}$${ACTIONS_ID_TOKEN_REQUEST_URL:-no}"; \
echo "ACTIONS_ID_TOKEN_REQUEST_TOKEN set: $${ACTIONS_ID_TOKEN_REQUEST_TOKEN:+yes}$${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-no}"; \
if [ -z "$${ACTIONS_ID_TOKEN_REQUEST_URL}" ] || [ -z "$${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" ]; then \
echo "OIDC env vars missing, skipping token exchange"; \
else \
oidc_token=$$(curl -sSf --retry 3 --retry-all-errors \
-H "Authorization: bearer $${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"$${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=quay.io" \
| jq -er '.value' || echo ""); \
echo "$$oidc_token" | grep -nc .; \
robot_token=$$(printf 'user = "cilium+quay_gh_release_tool:%s"\n' "$$oidc_token" \
| curl -sSf --retry 3 --retry-all-errors -K - \
"https://quay.io/oauth2/federation/robot/token" \
| jq -er '.token' || echo ""); \
echo "$$robot_token" | grep -nc .; \
fi

.PHONY: clean
clean:
rm -fr release bump-readme
Loading