Continuous Deployments
Automatically deploy your code to Jamsocket by creating a Github Workflow that uses Jamsocket’s Github Action.
When your Github Action is set up, you will see your git commit metadata displayed alongside your deployments.
Setting up your Github Workflow
Required Setup
The following options must be configured in order to make a deployment.
Key | Value Information | Type | Required |
---|---|---|---|
jamsocket_api_token | Your API token for Jamsocket authentication, which you can generate in Settings under Access Tokens. Store this API token as a secret in your repository’s Settings page under Security > Secrets and variables > Actions > Repository secrets. | with | Yes |
jamsocket_account | The name of your Jamsocket account, which can be found in Settings under Account > name. | with | Yes |
jamsocket_service | The name of the Jamsocket service you are pushing your code to. | with | Yes |
docker_build_context | The path to the directory that your Docker build should access. This is often the directory the Dockerfile is in. | with | Yes |
dockerfile_path | The path to your Dockerfile. | with | Yes |
tag | A custom tag to apply to the image. If provided, this image will only be used when this tag is provided in the spawn request. This can be used for preview deploy-like functionality. | with | No |
An example Github Action
Use the following example to deploy to Jamsocket whenever code is pushed to main.
Create a .github/workflows
directory.
Create a .github/workflows
directory in the root of your repository.
Create a Github Action
In your .github/workflows
directory, create a yaml file with any name e.g. deploy.yml
.
Paste the following code in deploy.yml
name: Deploy to Jamsocket
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Deploy to Jamsocket
uses: jamsocket/jamsocket-deploy-action@v1
with:
jamsocket_api_token: ${{ secrets.JAMSOCKET_API_TOKEN }}
jamsocket_account: my-jamsocket-account
jamsocket_service: my-jamsocket-service
docker_build_context: ./server
dockerfile_path: ./server/Dockerfile
tag: latest
Required variables
In the Github Action step, Deploy to Jamsocket
, there are required variables needed to successfully deploy to Jamsocket. Change the following variables to match your context:
jamsocket_api_token: ${{ secrets.JAMSOCKET_API_TOKEN }}
jamsocket_account: my-jamsocket-account
jamsocket_service: my-jamsocket-service
docker_build_context: ./server
dockerfile_path: ./server/Dockerfile
Store your Jamsocket API Token in your Github Repository
In order for your Github Action to push to Jamsocket, add your Jamsocket API token as a secret. To do so, navigate to your repository’s Settings page find the section under Security > Secrets and variables > Actions > Repository secrets.
To generate an API token from Jamsocket, go to Settings > Access Tokens.
Customize when Jamsocket deploys your code
Currently, this Github Action will push to Jamsocket whenever code is pushed to main. You can customize when you want to push to Jamsocket by editing this section of your yaml
file:
on:
push:
branches: [ "main" ]