GithubHelp home page GithubHelp logo

samkenxstream / action-deploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from npm/action-deploy

0.0 1.0 0.0 1.45 MB

Action to manage GitHub deployments

License: MIT License

TypeScript 98.95% JavaScript 1.05%

action-deploy's Introduction

Action to manage GitHub deployments

Features:

  • create a deployment (and invalidate all previous deployments)
  • delete all deployments in specific environment
  • delete a deployment by id

Usage

create

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

Example usage

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

delete-all

Allows 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

Example usage

- name: delete all deployments in staging
  uses: npm/action-deploy@v2
  with:
    type: delete-all
    token: ${{github.token}}
    environment: staging

delete

Given 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

Example usage

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

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:

$ 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

action-deploy's People

Contributors

demiracl avatar dependabot[bot] avatar gordey4doronin avatar radiantspace avatar tiagonbotelho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.