Skip to content

Commit 8e5aa5d

Browse files
authored
Merge pull request #518 from paoloredis/DOC-3991
DOC-3991 Use actions/create-github-app-token@v1 for getting app token
2 parents c1f0a7c + 96a0a4f commit 8e5aa5d

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

.github/workflows/k8s_apis_sync.yaml

+8-33
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,17 @@ jobs:
5959
sed -E -i 's/^<sup><sup>\[↩ Parent\]\(#redisenterpriseremotecluster/<sup><sup>\[↩ Parent\]\(#/g' artifacts/redis_enterprise_remote_cluster.md
6060
sed -E -i 's/<td><b><a href="#redisenterpriseremotecluster/<td><b><a href="#/' artifacts/redis_enterprise_remote_cluster.md
6161
62+
- name: Generate a token
63+
id: generate-token
64+
uses: actions/create-github-app-token@v1
65+
with:
66+
app-id: ${{ secrets.DOCS_APP_ID }}
67+
private-key: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
68+
6269
- name: 'Send pull request'
6370
env:
64-
APP_ID: ${{ secrets.DOCS_APP_ID }}
65-
PEM: ${{ secrets.DOCS_APP_PRIVATE_KEY }}
66-
REGISTRATION_ID: ${{ secrets.DOCS_APP_REGISTRATION_ID }}
71+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
6772
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-
9873
RELEASE="${{ github.event.inputs.release }}"
9974
BRANCH="k8s_apis_docs_${RELEASE}"
10075

0 commit comments

Comments
 (0)