Skip to content

Latest commit

 

History

History
78 lines (55 loc) · 2.96 KB

File metadata and controls

78 lines (55 loc) · 2.96 KB

Authentication

This guide covers how to authenticate the Qwen Code action in your GitHub Actions workflows.

Qwen Code API Authentication

The Qwen Code Action uses OpenAI-compatible API authentication through Alibaba Cloud's DashScope platform.

Prerequisites

Setup

  1. Create an API Key: Go to DashScope console and create a new API key.
  2. Add to GitHub Secrets: In your GitHub repository, go to Settings > Secrets and variables > Actions and add a new repository secret with the name QWEN_API_KEY and paste your key as the value.
  3. (Optional) Configure Base URL and Model: If you want to use a different endpoint or model, add repository variables:
    • QWEN_BASE_URL: Custom API endpoint (default: https://dashscope.aliyuncs.com/compatible-mode/v1)
    • QWEN_MODEL: Model name (default: qwen-coder-plus-latest)

Example

- uses: 'QwenLM/qwen-code-action@v1'
  with:
    prompt: |-
      Explain this code
    openai_api_key: '${{ secrets.QWEN_API_KEY }}'
    openai_base_url: '${{ vars.QWEN_BASE_URL }}' # Optional
    openai_model: '${{ vars.QWEN_MODEL }}' # Optional

GitHub Authentication

This action requires a GitHub token to interact with the GitHub API. You can authenticate in two ways:

Method 1: Using the Default GITHUB_TOKEN

For simpler scenarios, the action can authenticate using the default GITHUB_TOKEN that GitHub automatically creates for each workflow run.

Limitations:

  • Limited permissions - you may need to grant additional permissions in your workflow file
  • Job-scoped - access limited to the repository where the workflow runs
permissions:
  contents: 'read'
  issues: 'write'
  pull-requests: 'write'

Method 2: Using a GitHub App (Recommended)

For optimal security and control, create a custom GitHub App with fine-grained permissions.

  1. Create a new GitHub App at Settings > Developer settings > GitHub Apps
  2. Configure permissions (Contents, Issues, Pull requests: Read & write)
  3. Generate a private key and note the App ID
  4. Install the app in your repository
  5. Add APP_ID (variable) and APP_PRIVATE_KEY (secret) to your repository

For details, see the GitHub documentation.

Additional Resources