Fix iOS auth key: decode .p8 PEM from secret directly

Decode base64 ASC_API_KEY_P8 directly into the .p8 Tempfile so xcodebuild gets valid PEM. Admin-merge: only repo-wide pr.yml break failing.
This commit is contained in:
Jinwoo Hong 2026-06-15 23:10:31 -07:00 committed by GitHub
parent 3691267939
commit da386fae8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 5 deletions

View File

@ -12,6 +12,7 @@
# it across runs), which is why we import a .p12 into the keychain first.
require "tempfile"
require "base64"
default_platform(:ios)
@ -38,12 +39,14 @@ platform :ios do
# pre-imported into the keychain by the workflow; the API key only
# generates/downloads the provisioning profile.
#
# `app_store_connect_api_key` returns the DECODED key bytes in api_key[:key]
# (it does not write a file), so we materialize the .p8 ourselves for
# -authenticationKeyPath. Tempfile lives for the process; the runner VM is
# ephemeral so nothing secret persists.
# Why decode the secret ourselves instead of using api_key[:key]: feeding
# api_key[:key] to xcodebuild produced "Invalid authentication key
# credential (invalidPEMDocument)" — fastlane's stored value wasn't clean
# PEM. Decode the base64 secret directly so the .p8 is exactly the original
# PEM. Tempfile lives for the process; the runner VM is ephemeral so nothing
# secret persists.
key_file = Tempfile.new(["asc_api_key", ".p8"])
key_file.write(api_key[:key])
key_file.write(Base64.decode64(ENV.fetch("ASC_API_KEY_P8")))
key_file.close
auth_args =