Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ink-victor committed Feb 4, 2025
1 parent a0cff56 commit 45a78fb
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions .github/workflows/ship.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,38 +82,14 @@ jobs:
# docker-context: ./
# github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate GitHub App Token
id: generate-token
run: |
# Create a JWT using the app ID and private key
JWT_PAYLOAD=$(echo -n '{"iat":'"$(($(date +%s) - 60))"',"exp":'"$(($(date +%s) + 600))"',"iss":"${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_APP_ID }}"}' | base64 | tr -d '=' | tr '/+' '_-')
JWT_HEADER=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | tr -d '=' | tr '/+' '_-')
# Write private key to temp file
echo "${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_PRIVATE_KEY }}" > private-key.pem
# Sign the JWT
JWT_SIGNATURE=$(echo -n "${JWT_HEADER}.${JWT_PAYLOAD}" | openssl dgst -binary -sha256 -sign private-key.pem | openssl base64 | tr -d '=' | tr '/+' '_-')
JWT="${JWT_HEADER}.${JWT_PAYLOAD}.${JWT_SIGNATURE}"
# Exchange JWT for installation token
INSTALLATION_TOKEN=$(curl -s -X POST \
-H "Authorization: Bearer ${JWT}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/app/installations/${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_INSTALLATION_ID }}/access_tokens" \
| jq -r .token)
# Clean up
rm private-key.pem
# Set output
echo "token=${INSTALLATION_TOKEN}" >> $GITHUB_OUTPUT
- name: Trigger infra update
# https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
- name: Trigger deployment
if: github.ref == 'refs/heads/main2'
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.VICTOR_PAT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${{ secrets.TARGET_REPOSITORY_DISPATCH_URL }} \
-d '{"event_type": "update-test-file", "client_payload": {"message": "Test commit from GitHub Actions"}}'
-d '{"ref": "feat/ink-web-app-eks-app","inputs":{"message":"Update EKS image from GitHub Actions"}}'

0 comments on commit 45a78fb

Please sign in to comment.