Deploying with GitHub Actions
This guide explains how to set up a GitHub Action that automatically triggers a new deployment on Seenode whenever a commit is pushed to a specified branch.
Prerequisites
Section titled “Prerequisites”- A GitHub repository containing your application.
- An existing Seenode application linked to that repository.
- An API token for the Seenode API.
- Permissions to create GitHub Actions and manage repository secrets.
Getting an API Token
Learn how to generate and manage API tokens for authenticating with the Seenode API.-
Add Secrets to GitHub
To keep your credentials secure, store them as encrypted secrets in your GitHub repository.
- In your GitHub repository, go to Settings > Secrets and variables > Actions.
- Click New repository secret to add the following secrets:
SEENODE_APPLICATION_ID
: The ID of your Seenode application.SEENODE_API_TOKEN
: Your Seenode API token.
-
Create the GitHub Actions Workflow
Create a workflow file in your repository to define the deployment job.
- Create a
.github/workflows/
directory in your repository if it doesn’t already exist. - Inside this directory, create a new file named
deploy.yml
. - Add the following content to the
deploy.yml
file:
.github/workflows/deploy.yml name: Deploy to Seenodeon:push:branches:- main # Trigger the workflow on pushes to the main branchjobs:deploy:runs-on: ubuntu-lateststeps:- name: Trigger Seenode Deploymentrun: |curl -X POST \-H "Authorization: Bearer ${{ secrets.SEENODE_API_TOKEN }}" \-H "Content-Type: application/json" \-d '{"gitCommitSha": "${{ github.sha }}"}' \"https://api.seenode.com/v1/applications/${{ secrets.SEENODE_APPLICATION_ID }}/deployments"This workflow will be triggered on every push to the
main
branch. It sends a POST request to the Seenode API to trigger a new deployment using the latest commit. - Create a
-
Commit and Push
Commit the new workflow file to your repository to activate it.
Terminal git add .github/workflows/deploy.ymlgit commit -m "ci: Add GitHub Action for Seenode deployment"git push -
Verify the Deployment
Once you’ve pushed the workflow, you can verify that it’s working correctly.
- In your GitHub repository, go to the Actions tab. You should see the workflow running.
- In the Seenode Dashboard, navigate to your application’s Deployments tab. You should see a new deployment in progress.
Troubleshooting
Section titled “Troubleshooting”- Workflow Not Triggering: Ensure you are pushing to the correct branch specified in the
on.push.branches
section of your workflow file. - Authentication Error: Double-check that your
SEENODE_API_TOKEN
andSEENODE_APPLICATION_ID
secrets are correct and have no extra spaces or characters. - Invalid Request: Verify the API endpoint in the
curl
command. Ensure the application ID is correct.