File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 6161
6262 - name : ' Send pull request'
6363 env :
64- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ APP_ID : ${{ secrets.DOCS_APP_ID }}
65+ PEM : ${{ secrets.DOCS_APP_PRIVATE_KEY }}
66+ REGISTRATION_ID : ${{ secrets.DOCS_APP_REGISTRATION_ID }}
6567 run : |-
68+ set -o pipefail
69+ now=$(date +%s)
70+ iat=$((${now} - 60)) # Issues 60 seconds in the past
71+ exp=$((${now} + 600)) # Expires 10 minutes in the future
72+ b64enc() { openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n'; }
73+ header_json='{
74+ "typ":"JWT",
75+ "alg":"RS256"
76+ }'
77+ # Header encode
78+ header=$( echo -n "${header_json}" | b64enc )
79+ payload_json='{
80+ "iat":'"${iat}"',
81+ "exp":'"${exp}"',
82+ "iss":'"${APP_ID}"'
83+ }'
84+ # Payload encode
85+ payload=$( echo -n "${payload_json}" | b64enc )
86+ # Signature
87+ header_payload="${header}"."${payload}"
88+ signature=$(
89+ openssl dgst -sha256 -sign <(echo -n "${PEM}") \
90+ <(echo -n "${header_payload}") | b64enc
91+ )
92+ # Create JWT
93+ JWT="${header_payload}"."${signature}"
94+ GH_TOKEN=$(curl -s --request POST --url "https://api.github.com/app/installations/${REGISTRATION_ID}/access_tokens" \
95+ --header "Accept: application/vnd.github+json" --header "Authorization: Bearer $JWT" \
96+ --header "X-GitHub-Api-Version: 2022-11-28" | jq -r '.token')
97+
6698 RELEASE="${{ github.event.inputs.release }}"
6799 BRANCH="k8s_apis_docs_${RELEASE}"
68100
You can’t perform that action at this time.
0 commit comments