A repository that contains multiple reusable workflows that can be used in GitHub Actions.
Automatically deploys a project to a staging or a production environment based on a provided config file.
A GitHub Secret that will store the SSH key used to connect to the server.
When using this in an organization that runs multiple projects on the same server, you only need to create this secret once as a GitHub organization secret. It can then be used across all repository's with access, and it will be able to deploy all those repository's to different locations on that same server.
Steps:
- Generate an SSH private key that will give you access to your server.
- Create a new GitHub organization/repository secret with a recognizable name such as
DEPLOYMENT_SSH_PRIVATE_KEY. - Paste your SSH private key as the value of the GitHub Secret.
The action that runs every time you push to a given branch. This will deploy the repository.
Steps:
- Create a new workflow under the path
.github/workflows/YOUR_WORKFLOW_NAME. - Paste the following content in your workflow file.
# Workflow name
name: YOUR_WORKFLOW_NAME
# Events that trigger the workflow
on:
push:
branches: [
main,
dev
]
workflow_dispatch: # Triggered manually
# Jobs to run
jobs:
# Deploy
deploy:
uses: Stuurmen/pipelines/.github/workflows/deploy-v2.0.0.yml@main
secrets:
ssh_private_key: ${{ secrets.DEPLOYMENT_SSH_PRIVATE_KEY }}- Replace any placeholders with real data, and verify that the GitHub secret name below matches the name of your own GitHub secret.
name: Pipeline
on:
push:
branches: [
main,
dev
]
workflow_dispatch:
jobs:
deploy:
uses: Stuurmen/pipelines/.github/workflows/deploy-v2.0.0.yml@main
secrets:
ssh_private_key: ${{ secrets.DEPLOYMENT_SSH_PRIVATE_KEY }}A configuration file that indicates what should be deployed, and where it should be deployed.
Steps:
- Create a config file with the name
pipeline.jsonat the root of your project. - Paste the following file content.
{
"production": {
"branch": "PRODUCTION_BRANCH_NAME",
"host": "PRODUCTION_SSH_IP_ADDRESS",
"port": "PRODUCTION_SSH_PORT",
"username": "PRODUCTION_SSH_USERNAME",
"path": "REMOTE_PATH_TO_DEPLOY_TO",
"node_version": "NODE_VERSION",
},
"staging": {
"branch": "STAGING_BRANCH_NAME",
"host": "STAGING_SSH_IP_ADDRESS",
"port": "STAGING_SSH_PORT",
"username": "STAGING_SSH_USERNAME",
"path": "REMOTE_PATH_TO_DEPLOY_TO",
"node_version": "NODE_VERSION",
},
"source": {
"path": "PATH_TO_DIST",
"package_manager": "PACKAGE_MANAGER"
}
}- Replace the values in the configuration file with real data. An example can be found below.
{
"production": {
"branch": "main",
"host": "12.34.567.890",
"port": "12345",
"username": "admin",
"path": "./public/wp-content/themes/wordpress-theme-folder",
"node_version": "20"
},
"staging": {
"branch": "dev",
"host": "12.34.567.890",
"port": "67890",
"username": "admin",
"path": "./public/wp-content/themes/wordpress-theme-folder",
"node_version": "20"
},
"source": {
"path": "",
"package_manager": "yarn"
}
}