Features:
- create a deployment (and invalidate all previous deployments)
- delete all deployments in specific environment
- delete a deployment by id
Inputs:
| parameter | description |
|---|---|
token |
Required token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo |
type |
Required type of an action. Should be create to create a deployment |
logs |
url to the deployment logs |
environment |
environment to create a deployments in, default to $context.ref without prefixes ('refs/heads/', 'deploy-'), i.e. branch name |
environment_url |
link to the deployed application |
description |
optional description, defaults to "deployed by $context.actor" |
job_status |
pass ${{job.status}} to set the deployment completion status post script accordingly |
slack_token |
optional token of slack integration to post messages with deployment results |
slack_channel |
optional slack channel name (both slack_token and slack_channel are required to post a message) |
Outputs:
| output | description |
|---|---|
deployment_id |
The id of the created deployment |
- name: create a deployment
uses: npm/action-deploy@v2
with:
type: create
token: ${{github.token}}
logs: https://your-app.com/deployment_logs
environment: staging
environment_url: https://staging.your-app.com
job_status: ${{job.status}} # use this to track success of the deployment in post scriptAllows deleting all deployments for a specific environment
Inputs:
| parameter | description |
|---|---|
token |
Required token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo |
type |
Required type of an action. Should be delete-all |
environment |
environment to delete all deployments in |
Outputs: none
- name: delete all deployments in staging
uses: npm/action-deploy@v2
with:
type: delete-all
token: ${{github.token}}
environment: stagingGiven in one of the previous steps you created a deployment, with delete you can delete it by id
Inputs:
| parameter | description |
|---|---|
token |
Required token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo |
type |
Required type of an action. Should be delete |
deployment_id |
Required the id of the a deployment to delete |
Outputs: none
- name: create a deployment
uses: npm/action-deploy@v2
id: create-deployment
with:
type: create
token: ${{github.token}}
logs: https://your-app.com/deployment_logs
environment: staging
environment_url: https://staging.your-app.com
job_status: ${{job.status}}
# add your deployment steps here
- name: placeholder for actual deployment
run: sleep 10s
- name: delete deployment
uses: npm/action-deploy@v2
with:
type: delete
token: ${{github.token}}
deployment_id: ${{steps.create-deployment.outputs.deployment_id}}Install the dependencies
$ npm installBuild the typescript and package it for distribution
$ npm run build && npm run packRun the tests ✔️
$ npm run build && npm testThe action.yml contains defines the inputs and output for your action.
Update the action.yml with description, inputs and outputs for your action.
See the documentation
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
import * as core from '@actions/core';
...
async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}
run()See the toolkit documentation for the various packages.
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run pack
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1Your action is now published! 🚀
See the versioning documentation
You can now validate the action by referencing ./ in a workflow in your repo (see test.yml])
- uses: ./
name: Delete all deployments
with:
token: ${{github.token}}
type: delete-allSee the actions tab for runs of this action! 🚀
After testing you can create a v1 tag to reference the stable and latest V1 action