Deploying using GitHub actions

This guide explains how to set up a GitHub Action that automatically triggers a deployment to seenode whenever a commit is pushed to a specified branch.

Prerequisites

  1. A GitHub repository where you want to set up the action.

  2. A seenode application with an API endpoint for deployments.

  3. A JWT authentication token for the seenode API.

  4. Permissions to create GitHub Actions and manage repository secrets.

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.

    • SEENODE_JWT_TOKEN → Your JWT authentication token.

Find application ID in the browser URL: https://cloud.seenode.com/dashboard/applications?applicationId=969217#logs) ⇒ application ID is 969217

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:

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_JWT_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:

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 JWT token is correct and not expired.

    • Ensure that SEENODE_JWT_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.

Last updated