You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo "::error::Unable to connect to GitHub using the GH_PAT secret. Verify that it is set correctly (including the 'ghp_' or 'github_pat_' prefix) and try again."
47
+
else
48
+
echo "::error::Unable to connect to GitHub using the GH_PAT secret. Verify that the token exists and has not expired at https://github.com/settings/tokens. If necessary, regenerate or create a new token (and update the secret), then try again."
49
+
fi
50
+
elif [[ $scopes =~ workflow ]]; then
51
+
echo "The GH_PAT secret has repo and workflow permissions."
echo "The GH_PAT secret has repo (but not workflow) permissions."
55
+
elif [ $provides_scopes ]; then
56
+
failed=true
57
+
if [ -z "$scopes" ]; then
58
+
echo "The GH_PAT secret is valid and can be used to connect to GitHub, but it does not provide any permission scopes."
59
+
else
60
+
echo "The GH_PAT secret is valid and can be used to connect to GitHub, but it only provides the following permission scopes: $scopes"
61
+
fi
62
+
echo "::error::The GH_PAT secret is lacking at least the 'repo' permission scope required to access the Match-Secrets repository. Update the token permissions at https://github.com/settings/tokens (to include the 'repo' and 'workflow' scopes) and try again."
63
+
else
64
+
echo "The GH_PAT secret is valid and can be used to connect to GitHub, but it does not provide inspectable scopes. Assuming that the 'repo' and 'workflow' permission scopes required to access the Match-Secrets repository and perform automations are present."
echo "Created a private '${{ github.repository_owner }}/Match-Secrets' repository."
95
+
else
96
+
failed=true
97
+
echo "::error::Unable to create a private '${{ github.repository_owner }}/Match-Secrets' repository. Create a private 'Match-Secrets' repository manually and try again. If a private 'Match-Secrets' repository already exists, verify that the token permissions of the GH_PAT are set correctly (or update them) at https://github.com/settings/tokens and try again."
98
+
fi
99
+
# Otherwise, if a Match-Secrets repository exists, but it is public, cause validation to fail.
100
+
elif [[ "$visibility" == "public" ]]; then
101
+
failed=true
102
+
echo "::error::A '${{ github.repository_owner }}/Match-Secrets' repository was found, but it is public. Change the repository visibility to private (or delete it) and try again. If necessary, a private repository will be created for you."
103
+
else
104
+
echo "Found a private '${{ github.repository_owner }}/Match-Secrets' repository to use."
105
+
fi
106
+
107
+
# Exit unsuccessfully if secret validation failed.
echo "::error::TEAMID secret is unset or empty. Set it and try again."
135
+
echo "::error::The TEAMID secret is unset or empty. Set it and try again."
23
136
elif [ ${#TEAMID} -ne 10 ]; then
24
137
failed=true
25
-
echo "::error::TEAMID secret is set but has wrong length. Verify that it is set correctly and try again."
26
-
fi
27
-
28
-
# Validate GH_PAT
29
-
if [ -z "$GH_PAT" ]; then
138
+
echo "::error::The TEAMID secret is set but has wrong length. Verify that it is set correctly and try again."
139
+
elif ! [[ $TEAMID =~ ^[A-Z0-9]+$ ]]; then
30
140
failed=true
31
-
echo "::error::GH_PAT secret is unset or empty. Set it and try again."
32
-
elif [ "$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository_owner }}/Match-Secrets | jq --raw-output '.permissions.push')" != "true" ]; then
141
+
echo "::error::The TEAMID secret is set but invalid. Verify that it is set correctly (only uppercase letters and numbers) and try again."
142
+
fi
143
+
144
+
# Validate MATCH_PASSWORD
145
+
if [ -z "$MATCH_PASSWORD" ]; then
33
146
failed=true
34
-
echo "::error::GH_PAT secret is set but invalid or lacking appropriate privileges on the ${{ github.repository_owner }}/Match-Secrets repository. Verify that it is set correctly and try again."
147
+
echo "::error::The MATCH_PASSWORD secret is unset or empty. Set it and try again."
35
148
fi
36
-
149
+
150
+
# Ensure that fastlane exit codes are handled when output is piped.
151
+
set -o pipefail
152
+
37
153
# Validate FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY
if [ -z "$FASTLANE_ISSUER_ID" ] || [ -z "$FASTLANE_KEY_ID" ] || [ -z "$FASTLANE_KEY" ]; then
39
158
failed=true
40
159
[ -z "$FASTLANE_ISSUER_ID" ] && echo "::error::The FASTLANE_ISSUER_ID secret is unset or empty. Set it and try again."
41
160
[ -z "$FASTLANE_KEY_ID" ] && echo "::error::The FASTLANE_KEY_ID secret is unset or empty. Set it and try again."
42
161
[ -z "$FASTLANE_KEY" ] && echo "::error::The FASTLANE_KEY secret is unset or empty. Set it and try again."
43
-
elif ! echo "$FASTLANE_KEY" | openssl pkcs8 -nocrypt >/dev/null; then
162
+
elif [ ${#FASTLANE_KEY_ID} -ne 10 ]; then
44
163
failed=true
45
-
echo "::error::The FASTLANE_KEY secret is set but invalid. Verify that it is set correctly and try again."
46
-
elif ! fastlane validate_secrets; then
164
+
echo "::error::The FASTLANE_KEY_ID secret is set but has wrong length. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
165
+
elif ! [[ $FASTLANE_KEY_ID =~ $FASTLANE_KEY_ID_PATTERN ]]; then
47
166
failed=true
48
-
echo "::error::Unable to create a valid authorization token for the App Store Connect API.\
49
-
Verify that the FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY secrets are set correctly and try again."
50
-
fi
51
-
52
-
# Validate MATCH_PASSWORD
53
-
if [ -z "$MATCH_PASSWORD" ]; then
167
+
echo "::error::The FASTLANE_KEY_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
168
+
elif ! [[ $FASTLANE_ISSUER_ID =~ $FASTLANE_ISSUER_ID_PATTERN ]]; then
54
169
failed=true
55
-
echo "::error::The MATCH_PASSWORD secret is unset or empty. Set it and try again."
170
+
echo "::error::The FASTLANE_ISSUER_ID secret is set but invalid. Verify that you copied it correctly from the 'Keys' tab at https://appstoreconnect.apple.com/access/api and try again."
171
+
elif ! echo "$FASTLANE_KEY" | openssl pkcs8 -nocrypt >/dev/null; then
172
+
failed=true
173
+
echo "::error::The FASTLANE_KEY secret is set but invalid. Verify that you copied it correctly from the API Key file (*.p8) you downloaded and try again."
174
+
elif ! fastlane validate_secrets 2>&1 | tee fastlane.log; then
175
+
if grep -q "bad decrypt" fastlane.log; then
176
+
failed=true
177
+
echo "::error::Unable to decrypt the Match-Secrets repository using the MATCH_PASSWORD secret. Verify that it is set correctly and try again."
echo "::error::Unable to create a valid authorization token for the App Store Connect API. Verify that the latest developer program license agreement has been accepted at https://developer.apple.com/account (review and accept any updated agreement), then wait a few minutes for changes to propagate and try again."
181
+
elif ! grep -q -e "No code signing identity found" -e "Could not install WWDR certificate" fastlane.log; then
182
+
failed=true
183
+
echo "::error::Unable to create a valid authorization token for the App Store Connect API. Verify that the FASTLANE_ISSUER_ID, FASTLANE_KEY_ID, and FASTLANE_KEY secrets are set correctly and try again."
184
+
fi
56
185
fi
57
-
186
+
58
187
# Exit unsuccessfully if secret validation failed.
0 commit comments