You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从GitLab CI迁移至GitHub后,如何找到可用的dpl部署GitHub Action?

GitHub Actions Replacement for Your GitLab CI dpl Heroku Deployment

Hey there! Let's get your Heroku deployment working smoothly on GitHub Actions after moving from GitLab CI. Your original setup used dpl v1.8.47 to deploy the api directory, and we can replicate that exact workflow—or use a more native GitHub Action approach if you prefer.

Option 1: Mirror Your Original dpl Workflow

This setup matches your GitLab CI steps almost perfectly, using the same dpl version you relied on:

Create a new workflow file at .github/workflows/prod-deploy-api-developer.yml with this content:

name: Prod Deploy API Developer

# Adjust the trigger to match your needs (e.g., push to main, manual trigger, etc.)
on:
  push:
    branches: [ main ]

jobs:
  prod_deploy_api_developer:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository code
        uses: actions/checkout@v4

      - name: Set up consistent Ruby environment
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.1' # Works great for dpl v1.8.47; adjust if needed
          bundler-cache: false # We don't need bundler for this deployment

      - name: Install dpl v1.8.47 (exact version from your GitLab CI)
        run: gem install dpl -v 1.8.47

      - name: Deploy to Heroku
        working-directory: ./api
        run: dpl --provider=heroku --app=myapp --api-key=${{ secrets.HEROKU_API_KEY }} --skip-cleanup

Key Notes for This Option:

  • Checkout Step: GitHub Actions doesn't automatically pull your repo like GitLab CI does, so we add the actions/checkout step to get your code onto the runner.
  • Secrets: Replace the hardcoded mycrazykey with a GitHub Secret named HEROKU_API_KEY—store this in your repo's Settings > Secrets and variables > Actions to keep it secure.
  • Working Directory: The working-directory parameter replaces your cd ./api command, ensuring we run the deployment from the correct folder.

Option 2: Use the Official Heroku GitHub Action

If you want a more streamlined, native GitHub Actions experience, use the community-trusted Heroku deployment action. This avoids manually installing Ruby and dpl:

name: Prod Deploy API Developer

on:
  push:
    branches: [ main ]

jobs:
  prod_deploy_api_developer:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository code
        uses: actions/checkout@v4

      - name: Deploy to Heroku
        uses: akhileshns/heroku-deploy@v3.12.12
        with:
          heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
          heroku_app_name: "myapp"
          heroku_email: "your-heroku-email@example.com" # Use the email linked to your Heroku account
          appdir: "./api" # Targets only the api directory for deployment

Final Tips:

  • Trigger Adjustments: Modify the on section to run the deployment when you need it—for example, on release creation, pull request merges, or even manual triggers via the GitHub Actions tab.
  • Testing: Always test the workflow with a non-production app first to ensure everything connects correctly to Heroku.

内容的提问来源于stack exchange,提问作者Tiago Gouvêa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 19:13:01