Skip to content

Commit

Permalink
devops: add two inputs in action
Browse files Browse the repository at this point in the history
  • Loading branch information
linkinn committed Jun 14, 2022
1 parent 9779b6c commit f6d03c5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: 'Slack Send Message Clicksign'
description: 'Send message to slack and return thread id'
author: 'Team Devops'
inputs:
repo_name:
required: false
description: 'add repository github name'
repo_tag:
required: false
description: 'add repository github branch'
channel_id:
required: true
description: 'add channel id'
Expand Down
10 changes: 7 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import {slack} from './slack'

async function run(): Promise<void> {
try {
const repo = core.getInput('repo_name')
const repoTag = core.getInput('repo_tag')
const channelID = core.getInput('channel_id')
const payload = core.getInput('payload')
const threadTS = core.getInput('thread_ts')
const environment = core.getInput('environment')
const template = core.getInput('template')

slack({
repo,
repoTag,
channelID,
payload,
threadTS,
Expand Down
2 changes: 2 additions & 0 deletions src/slack-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface ISlack {
repo: string
repoTag: string
payload: string
channelID: string
threadTS: string
Expand Down
11 changes: 7 additions & 4 deletions src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {ISlack, IBlocks} from './slack-interface'
import templatesDefault from './templates-default'

export async function slack({
repo,
repoTag,
payload,
channelID,
threadTS,
Expand All @@ -16,10 +18,11 @@ export async function slack({
try {
const slackToken = process.env.SLACK_TOKEN
const webClient = new WebClient(slackToken)
const tag = context.ref.includes('refs/tags/')
? context.ref.slice(10)
: context.ref.slice(11)
const repoName = context.repo.repo
const tag =
repoTag || context.ref.includes('refs/tags/')
? context.ref.slice(10)
: context.ref.slice(11)
const repoName = repo || context.repo.repo
const runUrl = `${context.payload.repository?.html_url}/actions/runs/${context.runId}`
const text = templatesDefault({repoName, tag, environment})[template]

Expand Down

0 comments on commit f6d03c5

Please sign in to comment.