Skip to content

npm/action-deployment-notifications

 
 

Repository files navigation

Action to send npm service deployment notifications to Slack

Usage

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)

Example usage

- name: send deployment complete message to Slack
  uses: npm/action-deployment-notifications@v1
  with:
    environment: staging
    environment_url: https://staging.your-app.com
    job_status: ${{job.status}} # use this to track success of the deployment in post script

Development

Prerequisites

Install the dependencies

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run pack

Run the tests ✔️

$ npm run build && npm test

Update action.yml

The 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

Change the Code

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.

Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run ncc and push the results:

$ nvm install
$ npm run pack
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

Your action is now published! 🚀

See the versioning documentation

Validate

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-all

See the actions tab for runs of this action! 🚀

Deploy

After testing you can create a v1 tag to reference the stable and latest V1 action

About

Action to send npm service deployment notifications to Slack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.7%
  • JavaScript 3.3%