Skip to content

Repository files navigation

github-actions

A collection for the various Github actions used in Wiredcraft.

Workflows

Docker build

ParamsDescribeRequired
inputs.projectthe project name on Harbor for this imageYes
inputs.componentthe component name e.g. oms, it's usually the image name, by default it's github.event.repository.nameNo
inputs.node_envthe node env when build nodejs app, default productionNo
inputs.pushpush to remote registry or not ,default trueNo
inputs.docker_contextpath for docker build to execute, default ./No
inputs.docker_filethe Dockefile, default ./DockerfileNo
inputs.runnerrunner to run the docker build. default cnNo
secrets.REGISTRY_USERNAMEremote Harbor registry userYes
secrets.REGISTRY_PASSWORDremote Harbor registry passwordYes
secrets.NPM_TOKENnpm token to pull legacy npm private packagesNo
outputs.docker_tagstags from https://github.com/docker/metadata-action#outputs-
outputs.runnerthe Github Runner to run this build-

Simple build:

name: Build Docker imageon: [push]jobs:
build:
uses: Wiredcraft/github-actions/.github/workflows/docker_build.yml@masterwith:
project: internalsecrets:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}

Slack Statuc Notify

You can use this workflow to post status updates to Slack channel.

The possiable status are:

  • In Progress
  • Success
  • Failure
  • Cancelled
  • Skipped

e.g. image

ParamsDescribeRequired
inputs.statusone of success, failure, cancelled, skipped, it will be In Progress if no value givenNo
inputs.slack_channel_idthe channel id of the Slack channel, not the channel nameYes
inputs.msgthe status message to Slack, you can use mrkdwn syntaxYes
secrets.SLACK_BOT_TOKENthe OAuth app token of the Slack bot to send message in SlackYes

This is an example for how to use it in your workflow:

name: Hellorun-name: helloon:
push:
branches:
- masterjobs:
pre-slack-notify:
uses: Wiredcraft/github-actions/.github/workflows/slack_status_notify.yml@masterwith:
slack_channel_id: "CXXXXXXX"msg: "saying hello"secrets:
SLACK_BOT_TOKEN: ${{ secrets.YOUR_SLACK_BOT_TOKEN }}greeting:
runs-on: ubuntu-latestneeds: [pre-slack-notify]steps:
- name: Hellorun: echo "Hello!"post-slack-notify:
uses: Wiredcraft/github-actions/.github/workflows/slack_status_notify.yml@masterneeds: [greeting]if: ${{ always() }}with:
status: ${{ needs.greeting.result }}slack_channel_id: "CXXXXXXXX"msg: "said hello"secrets:
SLACK_BOT_TOKEN: ${{ secrets.YOUR_SLACK_BOT_TOKEN }}

Vulnerability Scannning

We use Trivy to scan the vulnerability in CI build pipelines. The enabled scan scope:

  • secret
  • vulnerability
ParamsDescribeRequired
inputs.docker_tagsthe meta tags from metadata-actionYes
inputs.runnerwhich runner to run this workflowYes
name: Build Docker imageon: [push]jobs:
build:
uses: Wiredcraft/github-actions/.github/workflows/docker_build.yml@masterwith:
project: internalsecrets:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}security:
needs: [build]name: scan vulnerabilitiesuses: Wiredcraft/github-actions/.github/workflows/vulnerability_scanning.yml@masterwith:
runner: ${{ needs.build.outputs.runner }}docker_tags: ${{ needs.build.outputs.docker_tags }}

Check Github user permission

ParamsDescribeRequred
inputs.tokenGithub Token with org member read only accessYes
inputs.orgGitub org for the team, by default it's WiredcraftNo
inputs.teamGithub team slugYes
inputs.usernameGithub user, suggest to use github.triggering_actor or github.actorYes
name: Send msg to Slackon: [push]jobs:
check-permission:
runs-on: ubuntu-latestoutputs:
allow: ${{ steps.check-github-permission.outputs.is_member }}steps:
- id: check-github-permissionuses: Wiredcraft/github-actions/check-github-user-permission@masterwith:
token: ${{ secrets.GITHUB_ORG_TOKEN }}team: devopsusername: ${{ github.triggering_actor || github.actor }}slack-notify:
uses: Wiredcraft/github-actions/.github/workflows/slack_status_notify.yml@masterneeds: [check-permission]if: needs.check-permission.outputs.allow == 'true'with:
slack_channel_id: "Cxxxxxx"#msg: "Hello this is a msg from Github Action"secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Create Grafana Annotation

ParamsDescribeRequired
inputs.tokenGrafana token to request Grafana HTTP annotation APIYes
inputs.hostGrafana API hostYes
inputs.textText of the annotationYes
inputs.timeTime for this annotation, by default it's Date.now()No
inputs.time_endTime for this annotation to end, by default it's emptyNo
inputs.dashboard_idId of the dashboard to add the annotation on, by default it apply to all dashboardsNo
inputs.panel_idId of the panel to add the annotation on, by default it apply to all panelsNo
inputs.tagsComma-separated list of tags assigned to the annotation, e.g. release, backendNo
name: Deploy backendon:
push:
branches:
- masterjobs:
grafana-annotation:
runs-on: cnsteps:
- uses: Wiredcraft/github-actions/create-grafana-annotation@masterwith:
token: ${{ secrets.GRAFANA_TOKEN }}host: ${{ vars.GRAFANA_HOST }}text: New releasedashboard_id: 1tags: 'release, backend'

Setup metamix

ParamsDescribeRequired
inputs.binary_download_urlthe url of metamix binary downloadYes
name: Setup metamixon:
push:
branches:
- masterjobs:
setup:
runs-on: cnsteps:
- uses: Wiredcraft/github-actions/metamix-setup@masterwith:
binary_download_url: 'https://example/metamix-linux-amd64'

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages