# Deploying using GitHub actions

### Prerequisites

1. A GitHub repository where you want to set up the action.
2. An Existing seenode application you want to deploy.
3. An API token for the seenode API.  👉 [Generate API token here](https://seenode.gitbook.io/docs/api/getting-an-api-token)
4. Permissions to create GitHub Actions and manage repository secrets.

{% content-ref url="../api/getting-an-api-token" %}
[getting-an-api-token](https://seenode.gitbook.io/docs/api/getting-an-api-token)
{% endcontent-ref %}

### **Step 1: Store sensitive data in GitHub secrets**

To keep your credentials secure, store them as **GitHub Secrets**:

1. Go to your repository in GitHub.
2. Navigate to **Settings → Secrets and variables → Actions**.
3. Click **New repository secret** and add the following secrets:
   * **`SEENODE_APPLICATION_ID`** → Your seenode application ID.&#x20;
   * **`SEENODE_API_TOKEN`** → Your API authentication token.&#x20;

{% hint style="info" %}
Find application ID in the browser URL: <https://cloud.seenode.com/dashboard/applications?applicationId=969217#logs>) ⇒ application ID is `969217`
{% endhint %}

### **Step 2: Create the GitHub actions workflow**

1. In your repository, create a new directory: `.github/workflows/` (if it doesn’t exist).
2. Inside the `.github/workflows/` directory, create a new file: `deploy.yml`.
3. Add the following content to `deploy.yml`:

```yaml
name: Deploy to seenode

on:
  push:
    branches:
      - main  # Change this if needed

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Send HTTP POST request to seenode API
        run: |
          curl -X POST "https://api.seenode.com/v1/applications/${{ secrets.SEENODE_APPLICATION_ID }}/deployments-new" \
            -H "Authorization: Bearer ${{ secrets.SEENODE_API_TOKEN }}" \
            -H "Content-Type: application/json" \
            -d '{
                  "gitCommitSha": "${{ github.sha }}"
                }'
```

### **Step 3: Commit and push the workflow**

1. Save the `deploy.yml` file.
2. Commit and push it to your repository:

```bash
git add .github/workflows/deploy.yml
git commit -m "Add GitHub Action for seenode deployment"
git push origin main
```

### **Step 4: Verify the Workflow Execution**

1. Go to your repository on GitHub.
2. Click on the **Actions** tab.
3. Locate the workflow run and verify that it executed successfully.
4. If there is an issue, click on the failed workflow run to check the logs for debugging.

### **Troubleshooting**

* **Workflow is not triggering?**
  * Ensure you are pushing to the correct branch (`main` by default in the workflow).
  * Check if Actions are enabled in your repository settings.
* **Authentication error?**
  * Verify that the **API token** is correct and not expired.
  * Ensure that `SEENODE_API_TOKEN` is set as a GitHub Secret.
* **Incorrect API endpoint?**
  * Double-check the **application ID** and the API URL format.

### Conclusion

You have now successfully set up a GitHub Action to automatically deploy to seenode when changes are pushed to the repository. This automation ensures that your deployments stay consistent and efficient.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://seenode.gitbook.io/docs/deploying/deploying-using-github-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
