If you wish to use GitHub Actions for your DeployHQ automatic deployments, you can add our [**deployhq-action**](https://github.com/deployhq/deployhq-action) to your repository, and set it up in a couple of minutes. The action installs the official [`dhq` CLI](https://github.com/deployhq/deployhq-cli) on the GitHub runner, triggers your deployment, waits for it to finish, and fails the job if the deploy didn’t succeed — so you get real status back in your workflow run instead of fire-and-forget.

You will need to add three secrets to your GitHub repository under *“Settings >> Secrets and variables >> Actions”*:

- `DEPLOYHQ_API_KEY` **(required)**: A DeployHQ API key. Generate one under *“Account Settings >> API access”*.
- `DEPLOYHQ_ACCOUNT` **(required)**: Your DeployHQ account subdomain (e.g. `acme` for `acme.deployhq.com`).
- `DEPLOYHQ_EMAIL` **(required)**: The email address of the DeployHQ user that owns the API key.

With these secrets added, copy the following YAML into your repository under `.github/workflows/deploy.yml`, replacing `my-project` and `production` with your project’s permalink and the server you want to deploy to:

```yaml
name: Deploy to DeployHQ
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger DeployHQ deployment
        uses: deployhq/deployhq-action@v2
        with:
          api-key: ${{ secrets.DEPLOYHQ_API_KEY }}
          account: ${{ secrets.DEPLOYHQ_ACCOUNT }}
          email:   ${{ secrets.DEPLOYHQ_EMAIL }}
          project: my-project
          server:  production
```

More details on workflow file syntax [can be found here](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).

Once set up, **make sure to delete** the DeployHQ webhook which was added automatically to your GitHub repository at the time of creation of your DeployHQ project, located in your GitHub repository under *“Settings >> Webhooks”*.

{screenshot: 573}

Not doing so may cause a *“double deployment”*, as a push to your repository will trigger both the integrated webhook in your GitHub repository, as well as the *deployhq-action* GitHub Action.

Once this is set up, you should be able to trigger automatic deployments to your desired server directly through the GitHub Action.

For the full list of inputs (`branch`, `revision`, `wait`, `dry-run`, `timeout`, etc.) and the migration guide from the previous webhook-based action, see the [GitHub README.md](https://github.com/deployhq/deployhq-action). If you’re not ready to migrate, the legacy webhook-based action is still available — pin `deployhq/deployhq-action@v1` and follow the v1 documentation.
