LoginSignup
3
1

More than 1 year has passed since last update.

GitHub ActionsでHerokuにデプロイする

Posted at

以下のリファレンスに書いてあるとおりに対応するだけです
https://github.com/marketplace/actions/deploy-to-heroku

ワークフローファイルを作成

github/workflows/main.yml
name: Deploy

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
        with:
          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
          heroku_app_name: ${{secrets.HEROKU_APP}}
          heroku_email: ${{secrets.HEROKU_EMAIL}}

GitHubにSecretを登録

ワークフローでsecretsを指定した項目を登録します

  • HEROKU_API_KEY
    • APIキーの取得方法は下記参照
  • HEROKU_APP
    • デプロイ先のHEROKUアプリ名を指定します
  • HEROKU_EMAIL
    • Herokuアカウントのメールアドレス

Settings -> Secretsから登録します

image.png

HerokuのAPI Key取得方法

  • HerokuのAccountSettingsのメニューから「API Key」でAPI Keyを生成します

image.png

GitHubへプッシュする

ここまでできたらあとはリモートのmasterブランチにプッシュするだけです

image.png

無事にワークフローが完了しました!
めちゃめちゃ簡単にHerokuデプロイできるので、対応しておいて損はないかと思います。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1