forked from anthropics/claude-code-action
-
Notifications
You must be signed in to change notification settings - Fork 170
68 lines (60 loc) · 3.13 KB
/
claude-oauth-login.yml
File metadata and controls
68 lines (60 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Claude OAuth Login (Simple)
on:
workflow_dispatch:
inputs:
authorization_code:
description: 'Authorization code from Claude OAuth (leave empty to generate URL)'
required: false
type: string
jobs:
oauth-login:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
- name: Generate OAuth URL or Process Code
run: |
if [ -z "${{ inputs.authorization_code }}" ]; then
# No code provided, generate URL
chmod +x .github/scripts/claude_oauth_login.rb
oauth_url=$(.github/scripts/claude_oauth_login.rb)
echo "## 🔐 Claude OAuth Login Instructions" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Step 1: Complete OAuth Authorization" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "1. Click this link to authenticate: [$oauth_url]($oauth_url)" >> $GITHUB_STEP_SUMMARY
echo "2. Log in to Anthropic and authorize the application" >> $GITHUB_STEP_SUMMARY
echo "3. Copy the authorization code from the redirect page" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Step 2: Run Workflow Again" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "1. Go to the [Actions tab](${{ github.server_url }}/${{ github.repository }}/actions/workflows/claude-oauth-login-simple.yml)" >> $GITHUB_STEP_SUMMARY
echo "2. Click 'Run workflow'" >> $GITHUB_STEP_SUMMARY
echo "3. Paste the authorization code in the input field" >> $GITHUB_STEP_SUMMARY
echo "4. Click 'Run workflow' to process the code" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **Important:** The authorization code expires in 10 minutes!" >> $GITHUB_STEP_SUMMARY
# Also output to logs
echo "=================================================="
echo "No authorization code provided."
echo "Please visit the following URL to authenticate:"
echo "$oauth_url"
echo ""
echo "After authorization, run this workflow again with the code."
echo "=================================================="
else
# Code provided, process it
echo "## ✅ Authorization Code Received" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Processing authorization code..." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Code:** \`${{ inputs.authorization_code }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Timestamp:** $(date)" >> $GITHUB_STEP_SUMMARY
# Here you would typically exchange the code for tokens
echo "Authorization code: ${{ inputs.authorization_code }}"
echo "Next step would be to exchange this code for access tokens"
fi