├── .eslintignore ├── .prettierignore ├── codecov.yml ├── docs ├── .dockerignore ├── netlify.toml ├── .gitignore ├── content │ ├── logo.png │ ├── migration.md │ ├── usecase.md │ ├── usage.md │ ├── usecase │ │ ├── 01-general.md │ │ └── 02-custom.md │ ├── index.md │ ├── contributors.md │ ├── fields.md │ ├── migration │ │ └── 01-migrate-from-v2-to-v3.md │ └── with.md ├── src │ ├── pwa-512.png │ ├── components │ │ ├── images │ │ │ ├── day.png │ │ │ ├── logo.png │ │ │ ├── night.png │ │ │ ├── closed.js │ │ │ ├── opened.js │ │ │ ├── help.svg │ │ │ ├── twitter-brands-block.svg │ │ │ ├── discord-brands-block.svg │ │ │ ├── twitter.svg │ │ │ └── github.svg │ │ ├── theme.js │ │ ├── mdxComponents │ │ │ ├── loading.js │ │ │ ├── LiveProvider.js │ │ │ ├── anchor.js │ │ │ ├── index.js │ │ │ └── codeBlock.js │ │ ├── index.js │ │ ├── search │ │ │ ├── styles.js │ │ │ ├── hitComps.js │ │ │ ├── input.js │ │ │ └── index.js │ │ ├── link.js │ │ ├── themeProvider.js │ │ ├── theme │ │ │ ├── index.js │ │ │ └── themeProvider.js │ │ ├── sidebar │ │ │ ├── treeNode.js │ │ │ ├── index.js │ │ │ └── tree.js │ │ ├── styles │ │ │ ├── Docs.js │ │ │ ├── Sidebar.js │ │ │ ├── PageNavigationButtons.js │ │ │ └── GlobalStyles.js │ │ ├── rightSidebar.js │ │ ├── DarkModeSwitch.js │ │ ├── layout.js │ │ ├── NextPrevious.js │ │ └── Header.js │ ├── custom-sw-code.js │ ├── GithubLink.js │ ├── YoutubeEmbed.js │ ├── utils │ │ └── algolia.js │ ├── CommunityAuthor.js │ ├── html.js │ └── templates │ │ └── docs.js ├── .prettierrc ├── .editorconfig ├── gatsby-browser.js ├── Dockerfile ├── LICENSE ├── .eslintrc.json ├── config.js ├── package.json ├── gatsby-node.js └── gatsby-config.js ├── .prettierrc.json ├── __tests__ ├── setupTest.ts ├── fixtures │ ├── actions.runs.jobs.json │ ├── actions.custom-job-name.jobs.json │ ├── actions.matrix-runs.jobs.json │ └── repos.commits.get.json ├── pull_request.test.ts ├── matrix.test.ts ├── customJobName.test.ts ├── incorrectMatrix.test.ts ├── helper.ts └── client.test.ts ├── jest.config.js ├── .github ├── workflows │ ├── star.yml │ ├── release.yml │ ├── uncommitted.yml │ ├── test-build.yml │ ├── slack-mainline.yml │ └── slack-pre.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── scripts └── prepare-release.sh ├── tsconfig.json ├── LICENSE ├── package.json ├── .gitignore ├── README.md ├── action.yml ├── .eslintrc.json └── src ├── main.ts ├── client.ts └── fields.ts /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | lib/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - __tests__/helper.ts 3 | -------------------------------------------------------------------------------- /docs/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | public 3 | .cache 4 | -------------------------------------------------------------------------------- /docs/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "public" 3 | command = "npm run build" 4 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | public 2 | .cache 3 | node_modules 4 | *DS_Store 5 | *.env 6 | 7 | .idea/ 8 | -------------------------------------------------------------------------------- /docs/content/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/action-slack/master/docs/content/logo.png -------------------------------------------------------------------------------- /docs/src/pwa-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/action-slack/master/docs/src/pwa-512.png -------------------------------------------------------------------------------- /docs/src/components/images/day.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/action-slack/master/docs/src/components/images/day.png -------------------------------------------------------------------------------- /docs/src/components/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/action-slack/master/docs/src/components/images/logo.png -------------------------------------------------------------------------------- /docs/src/components/images/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/action-slack/master/docs/src/components/images/night.png -------------------------------------------------------------------------------- /docs/src/components/theme.js: -------------------------------------------------------------------------------- 1 | export default { 2 | fonts: { 3 | mono: '"SF Mono", "Roboto Mono", Menlo, monospace', 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /docs/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "jsxBracketSameLine": false, 4 | "singleQuote": true, 5 | "tabWidth": 2, 6 | "trailingComma": "es5" 7 | } 8 | -------------------------------------------------------------------------------- /docs/content/migration.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Migration 3 | metaTitle: Migration | action-slack 4 | metaDescription: This page describes how to update the major version. 5 | --- 6 | -------------------------------------------------------------------------------- /docs/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /docs/src/custom-sw-code.js: -------------------------------------------------------------------------------- 1 | workbox.routing.registerRoute( 2 | new RegExp('https:.*min.(css|js)'), 3 | workbox.strategies.staleWhileRevalidate({ 4 | cacheName: 'cdn-cache', 5 | }) 6 | ); 7 | -------------------------------------------------------------------------------- /docs/src/components/mdxComponents/loading.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | const LoadingProvider = ({ ...props }) => { 4 | return
; 5 | }; 6 | 7 | export default LoadingProvider; 8 | -------------------------------------------------------------------------------- /docs/src/components/index.js: -------------------------------------------------------------------------------- 1 | export * from './theme'; 2 | export mdxComponents from './mdxComponents'; 3 | export ThemeProvider from './theme/themeProvider'; 4 | export Layout from './layout'; 5 | export Link from './link'; 6 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "all", 8 | "bracketSpacing": true, 9 | "arrowParens": "avoid", 10 | "parser": "typescript" 11 | } 12 | -------------------------------------------------------------------------------- /docs/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | export const onServiceWorkerUpdateReady = () => { 2 | const answer = window.confirm( 3 | `This tutorial has been updated. ` + 4 | `Reload to display the latest version?` 5 | ) 6 | if (answer === true) { 7 | window.location.reload() 8 | } 9 | } -------------------------------------------------------------------------------- /docs/content/usecase.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Use case 3 | metaTitle: Use case | action-slack 4 | metaDescription: This describes the usecase of action-slack. 5 | --- 6 | 7 | This page introduces a use case using action-slack. 8 | 9 | - [General use case](/usecase/01-general) 10 | - [Custom use case](/usecase/02-custom) 11 | -------------------------------------------------------------------------------- /docs/src/components/images/closed.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ClosedSvg = () => ( 4 | 5 | 6 | 7 | ); 8 | 9 | export default ClosedSvg; 10 | -------------------------------------------------------------------------------- /docs/src/components/images/opened.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const OpenedSvg = () => ( 4 | 5 | 6 | 7 | ); 8 | 9 | export default OpenedSvg; 10 | -------------------------------------------------------------------------------- /docs/src/components/search/styles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Algolia } from 'styled-icons/fa-brands/Algolia'; 3 | 4 | export const PoweredBy = () => ( 5 | 6 | Powered by{` `} 7 | 8 | Algolia 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /docs/src/GithubLink.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | const githubIcon = require('./components/images/github.svg'); 3 | 4 | const GithubLink = ({ link, text }) => { 5 | return ( 6 | 7 | github 8 | {text} 9 | 10 | ); 11 | }; 12 | 13 | export default GithubLink; 14 | -------------------------------------------------------------------------------- /docs/src/components/link.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link as GatsbyLink } from 'gatsby'; 3 | import isAbsoluteUrl from 'is-absolute-url'; 4 | 5 | const Link = ({ to, ...props }) => 6 | isAbsoluteUrl(to) ? ( 7 | 8 | {props.children} 9 | 10 | ) : ( 11 | 12 | ); 13 | 14 | export default Link; 15 | -------------------------------------------------------------------------------- /docs/src/components/mdxComponents/LiveProvider.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live'; 3 | 4 | const ReactLiveProvider = ({ code }) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | export default ReactLiveProvider; 15 | -------------------------------------------------------------------------------- /__tests__/setupTest.ts: -------------------------------------------------------------------------------- 1 | module.exports = async () => { 2 | process.env.GITHUB_REPOSITORY = '8398a7/action-slack'; 3 | process.env.GITHUB_WORKFLOW = 'PR Checks'; 4 | process.env.GITHUB_SHA = 'b24f03a32e093fe8d55e23cfd0bb314069633b2f'; 5 | process.env.GITHUB_REF = 'refs/heads/feature/19'; 6 | process.env.GITHUB_EVENT_NAME = 'push'; 7 | process.env.GITHUB_RUN_ID = '1'; 8 | process.env.GITHUB_JOB = 'notification'; 9 | }; 10 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | clearMocks: true, 3 | moduleFileExtensions: ['js', 'ts'], 4 | testEnvironment: 'node', 5 | testMatch: ['**/*.test.ts'], 6 | testRunner: 'jest-circus/runner', 7 | transform: { 8 | '^.+\\.ts$': 'ts-jest', 9 | }, 10 | verbose: true, 11 | coverageDirectory: './coverage/', 12 | collectCoverage: true, 13 | preset: 'ts-jest', 14 | globalSetup: './__tests__/setupTest.ts', 15 | }; 16 | -------------------------------------------------------------------------------- /.github/workflows/star.yml: -------------------------------------------------------------------------------- 1 | name: Star 2 | 3 | on: [watch] 4 | 5 | jobs: 6 | star: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: 8398a7/action-slack@v3 10 | with: 11 | status: ${{ job.status }} 12 | fields: repo 13 | text: " Star from ${{ github.event.sender.login }}, Total: ${{ github.event.repository.stargazers_count }}" 14 | env: 15 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 16 | -------------------------------------------------------------------------------- /docs/src/components/search/hitComps.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Highlight, Snippet } from 'react-instantsearch-dom'; 3 | import { Link } from 'gatsby'; 4 | 5 | export const PageHit = clickHandler => ({ hit }) => ( 6 |
7 | 8 |
9 | 10 |
11 | 12 | 13 |
14 | ); 15 | -------------------------------------------------------------------------------- /docs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:buster 2 | 3 | # Create app directory 4 | WORKDIR /app 5 | 6 | # Install app dependencies 7 | # RUN npm -g install serve 8 | RUN npm -g install gatsby-cli 9 | 10 | COPY package*.json ./ 11 | 12 | RUN npm ci 13 | 14 | # Bundle app source 15 | COPY . . 16 | 17 | # Build static files 18 | RUN npm run build 19 | 20 | # serve on port 8080 21 | # CMD ["serve", "-l", "tcp://0.0.0.0:8080", "public"] 22 | CMD ["gatsby", "serve", "--verbose", "--prefix-paths", "-p", "8080", "--host", "0.0.0.0"] 23 | -------------------------------------------------------------------------------- /docs/src/YoutubeEmbed.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const YoutubeEmbed = ({ link }) => { 4 | return ( 5 |
6 | 15 |
16 | ); 17 | }; 18 | 19 | export default YoutubeEmbed; 20 | -------------------------------------------------------------------------------- /docs/src/components/themeProvider.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming'; 3 | import { default as defaultTheme } from './theme'; 4 | import Header from './Header'; 5 | 6 | export default function ThemeProvider({ children, theme = {}, location }) { 7 | return ( 8 |
9 |
10 | {children} 11 |
12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - "v*" 5 | 6 | name: Create Release 7 | 8 | jobs: 9 | build: 10 | name: Create Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Create Release 15 | uses: actions/create-release@v1 16 | env: 17 | GITHUB_TOKEN: ${{ github.token }} 18 | with: 19 | tag_name: ${{ github.ref }} 20 | release_name: Release ${{ github.ref }} 21 | draft: false 22 | prerelease: false 23 | -------------------------------------------------------------------------------- /docs/content/usage.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Usage 3 | metaTitle: Usage | action-slack 4 | metaDescription: This is usage to action-slack. 5 | --- 6 | 7 | ```yaml 8 | steps: 9 | - uses: 8398a7/action-slack@v3 10 | with: 11 | status: ${{ job.status }} 12 | author_name: Integration Test # default: 8398a7@action-slack 13 | fields: repo,commit,message,author # default: repo,commit 14 | mention: here 15 | if_mention: failure,cancelled 16 | env: 17 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required 18 | if: always() # Pick up events even if the job fails or is canceled. 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/src/components/images/help.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/src/components/mdxComponents/anchor.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Link as GatsbyLink } from 'gatsby'; 3 | import isAbsoluteUrl from 'is-absolute-url'; 4 | 5 | const AnchorTag = ({ children: link, ...props }) => { 6 | if (!link) return null; 7 | 8 | if (isAbsoluteUrl(props.href)) { 9 | return ( 10 | 11 | {link} 12 | 13 | ); 14 | } else { 15 | return ( 16 | 17 | {link} 18 | 19 | ); 20 | } 21 | }; 22 | 23 | export default AnchorTag; 24 | -------------------------------------------------------------------------------- /docs/src/components/theme/index.js: -------------------------------------------------------------------------------- 1 | const baseTheme = { 2 | fonts: { 3 | mono: '"SF Mono", "Roboto Mono", Menlo, monospace', 4 | }, 5 | }; 6 | 7 | const lightTheme = { 8 | ...baseTheme, 9 | colors: { 10 | background: '#fff', 11 | heading: '#000', 12 | text: '#3B454E', 13 | preFormattedText: 'rgb(245, 247, 249)', 14 | link: '#1000EE', 15 | }, 16 | }; 17 | 18 | const darkTheme = { 19 | ...baseTheme, 20 | colors: { 21 | background: '#001933', 22 | heading: '#fff', 23 | text: '#fff', 24 | preFormattedText: '#000', 25 | link: '#1ED3C6', 26 | }, 27 | }; 28 | 29 | export { lightTheme, darkTheme }; 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Please describe the yaml of GitHub Actions that we can reproduce. 15 | Please don't write excerpts as the whole setup will affect the behavior. 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Additional context** 24 | Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /docs/src/components/images/twitter-brands-block.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/uncommitted.yml: -------------------------------------------------------------------------------- 1 | name: Check for uncommitted changes 2 | on: 3 | push: 4 | branches: 5 | - pre 6 | - "v*" 7 | 8 | jobs: 9 | uncommitted: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - run: npm ci 14 | - uses: actions/cache@v2 15 | with: 16 | path: ~/.npm 17 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 18 | restore-keys: | 19 | ${{ runner.os }}-node- 20 | - run: npm install 21 | - run: npm run release 22 | - name: check for uncommitted changes 23 | run: | 24 | git diff --exit-code --stat -- . ':!node_modules' \ 25 | || (echo "##[error] found changed files after build. please 'npm run build && npm run format'" \ 26 | "and check in all changes" \ 27 | && exit 1) 28 | -------------------------------------------------------------------------------- /docs/content/usecase/01-general.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: General use case 3 | metaTitle: General use case | action-slack 4 | metaDescription: This describes the general use case of action-slack. 5 | --- 6 | 7 | Notify slack of the results of a single job run. 8 | 9 | ```yaml 10 | steps: 11 | - uses: 8398a7/action-slack@v3 12 | with: 13 | status: ${{ job.status }} 14 | fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message) 15 | env: 16 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required 17 | if: always() # Pick up events even if the job fails or is canceled. 18 | ``` 19 | 20 | `status: ${{ job.status }}` allows a job to succeed, fail or cancel etc. to action-slack. 21 | `if: always()` to trigger action-slack even if the job fails Let them. 22 | 23 | For the fields, look at [Fields](/fields) to determine what you want. 24 | -------------------------------------------------------------------------------- /scripts/prepare-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -u 2 | 3 | git diff HEAD~..HEAD -- package-lock.json | grep -q '"version":' 4 | if [ $? = 1 ]; then 5 | exit 0 6 | fi 7 | git diff HEAD~..HEAD -- package.json | grep -q '"version":' 8 | if [ $? = 1 ]; then 9 | exit 0 10 | fi 11 | 12 | echo start release flow 13 | 14 | # setup git 15 | git config user.name "8398a7" 16 | git config user.email "8398a7@gmail.com" 17 | 18 | tag=$(git diff HEAD~..HEAD -- package.json | grep version | tail -n 1 | cut -d'"' -f4) 19 | major=$(echo ${tag:0:1}) 20 | tag=v$tag 21 | 22 | # release flow 23 | git checkout v$major 24 | git merge origin/master 25 | npm ci 26 | npm install 27 | npm run release 28 | git add -A 29 | git commit -m '[command] npm run release' 30 | git remote add github "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" 31 | git push github v$major 32 | 33 | # push tag 34 | git tag $tag 35 | git push github --tags 36 | -------------------------------------------------------------------------------- /docs/src/utils/algolia.js: -------------------------------------------------------------------------------- 1 | const config = require('../../config.js'); 2 | 3 | const pageQuery = `{ 4 | pages: allMdx { 5 | edges { 6 | node { 7 | objectID: id 8 | fields { 9 | slug 10 | } 11 | headings { 12 | value 13 | } 14 | frontmatter { 15 | title 16 | metaDescription 17 | } 18 | excerpt(pruneLength: 50000) 19 | } 20 | } 21 | } 22 | }`; 23 | 24 | const flatten = arr => 25 | arr.map(({ node: { frontmatter, fields, ...rest } }) => ({ 26 | ...frontmatter, 27 | ...fields, 28 | ...rest, 29 | })); 30 | 31 | const settings = { attributesToSnippet: [`excerpt:20`] }; 32 | 33 | const indexName = config.header.search ? config.header.search.indexName : ''; 34 | 35 | const queries = [ 36 | { 37 | query: pageQuery, 38 | transformer: ({ data }) => flatten(data.pages.edges), 39 | indexName: `${indexName}`, 40 | settings, 41 | }, 42 | ]; 43 | 44 | module.exports = queries; 45 | -------------------------------------------------------------------------------- /docs/src/components/images/discord-brands-block.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /__tests__/fixtures/actions.runs.jobs.json: -------------------------------------------------------------------------------- 1 | { 2 | "total_count": 1, 3 | "jobs": [ 4 | { 5 | "id": 762195612, 6 | "run_id": 132308092, 7 | "run_url": "https://api.github.com/repos/8398a7/action-slack/actions/runs/132308092", 8 | "node_id": "MDg6Q2hlY2tSdW43NjIxOTU2MTI=", 9 | "head_sha": "cd15a66fc57d465564195faeb5308a63b4317cde", 10 | "url": "https://api.github.com/repos/8398a7/action-slack/actions/jobs/762195612", 11 | "html_url": "https://github.com/8398a7/action-slack/runs/762195612", 12 | "status": "in_progress", 13 | "conclusion": null, 14 | "started_at": "2020-06-11T15:05:49Z", 15 | "completed_at": null, 16 | "name": "notification", 17 | "steps": [ 18 | { 19 | "name": "Set up job", 20 | "status": "in_progress", 21 | "conclusion": null, 22 | "number": 1, 23 | "started_at": "2020-06-11T15:05:49.000Z", 24 | "completed_at": null 25 | } 26 | ], 27 | "check_run_url": "https://api.github.com/repos/8398a7/action-slack/check-runs/762195612" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "outDir": "./lib", /* Redirect output structure to the directory. */ 6 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 7 | "strict": true, /* Enable all strict type-checking options. */ 8 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | }, 11 | "exclude": ["node_modules", "**/*.test.ts", "__tests__/*.ts"], 12 | } 13 | -------------------------------------------------------------------------------- /docs/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Hasura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /__tests__/fixtures/actions.custom-job-name.jobs.json: -------------------------------------------------------------------------------- 1 | { 2 | "total_count": 1, 3 | "jobs": [ 4 | { 5 | "id": 762195612, 6 | "run_id": 132308092, 7 | "run_url": "https://api.github.com/repos/8398a7/action-slack/actions/runs/132308092", 8 | "node_id": "MDg6Q2hlY2tSdW43NjIxOTU2MTI=", 9 | "head_sha": "cd15a66fc57d465564195faeb5308a63b4317cde", 10 | "url": "https://api.github.com/repos/8398a7/action-slack/actions/jobs/762195612", 11 | "html_url": "https://github.com/8398a7/action-slack/runs/762195612", 12 | "status": "in_progress", 13 | "conclusion": null, 14 | "started_at": "2020-06-11T15:05:49Z", 15 | "completed_at": null, 16 | "name": "Custom Job (ubuntu-18.04)", 17 | "steps": [ 18 | { 19 | "name": "Set up job", 20 | "status": "in_progress", 21 | "conclusion": null, 22 | "number": 1, 23 | "started_at": "2020-06-11T15:05:49.000Z", 24 | "completed_at": null 25 | } 26 | ], 27 | "check_run_url": "https://api.github.com/repos/8398a7/action-slack/check-runs/762195612" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /__tests__/fixtures/actions.matrix-runs.jobs.json: -------------------------------------------------------------------------------- 1 | { 2 | "total_count": 1, 3 | "jobs": [ 4 | { 5 | "id": 762195612, 6 | "run_id": 132308092, 7 | "run_url": "https://api.github.com/repos/8398a7/action-slack/actions/runs/132308092", 8 | "node_id": "MDg6Q2hlY2tSdW43NjIxOTU2MTI=", 9 | "head_sha": "cd15a66fc57d465564195faeb5308a63b4317cde", 10 | "url": "https://api.github.com/repos/8398a7/action-slack/actions/jobs/762195612", 11 | "html_url": "https://github.com/8398a7/action-slack/runs/762195612", 12 | "status": "in_progress", 13 | "conclusion": null, 14 | "started_at": "2020-06-11T15:05:49Z", 15 | "completed_at": null, 16 | "name": "notification (ubuntu-18.04)", 17 | "steps": [ 18 | { 19 | "name": "Set up job", 20 | "status": "in_progress", 21 | "conclusion": null, 22 | "number": 1, 23 | "started_at": "2020-06-11T15:05:49.000Z", 24 | "completed_at": null 25 | } 26 | ], 27 | "check_run_url": "https://api.github.com/repos/8398a7/action-slack/check-runs/762195612" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 8398a7, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /docs/src/components/images/twitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /docs/src/components/images/github.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 12 | 13 | -------------------------------------------------------------------------------- /docs/content/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: action-slack 3 | metaTitle: action-slack 4 | metaDescription: You can notify slack of GitHub Actions. 5 | --- 6 | 7 | ![](https://github.com/8398a7/action-slack/workflows/build-test/badge.svg) 8 | ![](https://github.com/8398a7/action-slack/workflows/Slack%20Mainline/badge.svg) 9 | ![](https://img.shields.io/github/license/8398a7/action-slack?color=brightgreen) 10 | ![](https://img.shields.io/github/v/release/8398a7/action-slack?color=brightgreen) 11 | [![codecov](https://codecov.io/gh/8398a7/action-slack/branch/master/graph/badge.svg)](https://codecov.io/gh/8398a7/action-slack) 12 | 13 | You can notify slack of GitHub Actions. 14 | 15 | - [Usage](/usage) 16 | - [v2 Document Link](https://github.com/8398a7/action-slack/blob/v2/README.md) 17 | 18 | ```yaml 19 | steps: 20 | - uses: 8398a7/action-slack@v3 21 | with: 22 | status: ${{ job.status }} 23 | fields: repo,message,commit,author,action,eventName,ref,workflow # selectable (default: repo,message) 24 | env: 25 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required 26 | if: always() # Pick up events even if the job fails or is canceled. 27 | ``` 28 | 29 | success 30 | -------------------------------------------------------------------------------- /docs/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:import/errors", 5 | "plugin:react/recommended", 6 | "plugin:jsx-a11y/recommended", 7 | "prettier", 8 | "prettier/react" 9 | ], 10 | "plugins": ["react", "import", "jsx-a11y"], 11 | "settings": { 12 | "react": { 13 | "version": "detect" 14 | } 15 | }, 16 | "rules": { 17 | "react/prop-types": 0, 18 | "react/react-in-jsx-scope": "off", 19 | "lines-between-class-members": ["error", "always"], 20 | "padding-line-between-statements": [ 21 | "error", 22 | { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, 23 | { 24 | "blankLine": "always", 25 | "prev": ["const", "let", "var"], 26 | "next": ["const", "let", "var"] 27 | }, 28 | { "blankLine": "always", "prev": "directive", "next": "*" }, 29 | { "blankLine": "any", "prev": "directive", "next": "directive" } 30 | ] 31 | }, 32 | "parser": "babel-eslint", 33 | "parserOptions": { 34 | "ecmaVersion": 10, 35 | "sourceType": "module", 36 | "ecmaFeatures": { 37 | "jsx": true 38 | } 39 | }, 40 | "env": { 41 | "es6": true, 42 | "browser": true, 43 | "node": true 44 | }, 45 | "globals": { 46 | "graphql": false 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /__tests__/pull_request.test.ts: -------------------------------------------------------------------------------- 1 | import nock from 'nock'; 2 | 3 | process.env.GITHUB_EVENT_NAME = 'pull_request'; 4 | 5 | import { setupNockCommit, getTemplate, newWith, githubToken } from './helper'; 6 | import { Client, With, Success } from '../src/client'; 7 | 8 | beforeAll(() => { 9 | nock.disableNetConnect(); 10 | setupNockCommit(process.env.GITHUB_SHA as string); 11 | }); 12 | afterAll(() => { 13 | nock.cleanAll(); 14 | nock.enableNetConnect(); 15 | }); 16 | 17 | describe('pull request event', () => { 18 | it('works on pull request event', async () => { 19 | const github = require('@actions/github'); 20 | const sha = 'expected-sha-for-pull_request_event'; 21 | github.context.payload = { 22 | pull_request: { 23 | number: 123, 24 | head: { sha }, 25 | }, 26 | }; 27 | github.context.eventName = 'pull_request'; 28 | 29 | const withParams = { 30 | ...newWith(), 31 | status: Success, 32 | mention: 'user_id', 33 | if_mention: Success, 34 | fields: 'action', 35 | }; 36 | const client = new Client(withParams, githubToken, ''); 37 | const msg = 'mention test'; 38 | const payload = getTemplate(withParams.fields, `<@user_id> ${msg}`, sha); 39 | payload.attachments[0].color = 'good'; 40 | expect(await client.prepare(msg)).toStrictEqual(payload); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /docs/content/contributors.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributors 3 | metaTitle: Contributors | action-slack 4 | metaDescription: This describes how to contribute to action-slack. 5 | --- 6 | 7 | ### Checkin 8 | 9 | - Do checkin source (src) 10 | - Do checkin build output (lib) 11 | - Do checkin runtime node_modules 12 | - Do not checkin devDependency node_modules (husky can help see below) 13 | 14 | ### devDependencies 15 | 16 | In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. 17 | This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: 18 | 19 | ``` 20 | npm install # installs all devDependencies including Husky 21 | git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) 22 | git commit -m "Informative commit message" # Commit. This will run Husky 23 | ``` 24 | 25 | During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. 26 | It will also make sure these changes are appropriately included in your commit (no further work is needed) 27 | -------------------------------------------------------------------------------- /.github/workflows/test-build.yml: -------------------------------------------------------------------------------- 1 | name: test-build 2 | on: [pull_request, push] 3 | 4 | jobs: 5 | test: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | - uses: actions/cache@v2 10 | with: 11 | path: ~/.npm 12 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 13 | restore-keys: | 14 | ${{ runner.os }}-node- 15 | - run: npm install 16 | - run: npm run all 17 | env: 18 | GITHUB_TOKEN: ${{ github.token }} 19 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 20 | - uses: 8398a7/action-slack@v3 21 | with: 22 | status: ${{ job.status }} 23 | fields: repo,message,job,took 24 | env: 25 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 26 | if: ${{ github.event_name != 'pull_request' }} 27 | prepare-release: 28 | if: contains(github.ref, 'master') 29 | needs: [test] 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v1 33 | - uses: actions/cache@v2 34 | with: 35 | path: ~/.npm 36 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 37 | restore-keys: | 38 | ${{ runner.os }}-node- 39 | - run: npm run prepare-release 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # Use personal access token to trigger another workflow. 42 | -------------------------------------------------------------------------------- /docs/src/components/mdxComponents/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import styled from '@emotion/styled'; 3 | 4 | import CodeBlock from './codeBlock'; 5 | import AnchorTag from './anchor'; 6 | 7 | const StyledPre = styled('pre')` 8 | padding: 16px; 9 | background: ${props => props.theme.colors.preFormattedText}; 10 | `; 11 | 12 | export default { 13 | h1: props => ( 14 |

15 | ), 16 | h2: props => ( 17 |

18 | ), 19 | h3: props => ( 20 |

21 | ), 22 | h4: props => ( 23 |

24 | ), 25 | h5: props => ( 26 |

27 | ), 28 | h6: props => ( 29 |
30 | ), 31 | p: props =>

, 32 | pre: props => ( 33 | 34 |

35 |     
36 |   ),
37 |   code: CodeBlock,
38 |   a: AnchorTag,
39 |   // TODO add `img`
40 |   // TODO add `blockquote`
41 |   // TODO add `ul`
42 |   // TODO add `li`
43 |   // TODO add `table`
44 | };
45 | 


--------------------------------------------------------------------------------
/docs/src/CommunityAuthor.js:
--------------------------------------------------------------------------------
 1 | import React from 'react';
 2 | 
 3 | const CommunityAuthor = ({ name, imageUrl, twitterUrl, githubUrl, description }) => {
 4 |   return (
 5 |     <>
 6 |       

About the community author

7 |
8 |
9 | {name} 10 |
11 |
12 |
13 | {name} 14 | {twitterUrl ? ( 15 | 16 | Twitter Icon 21 | 22 | ) : null} 23 | {githubUrl ? ( 24 | 25 | Github Icon 30 | 31 | ) : null} 32 |
33 |
{description}
34 |
35 |
36 | 37 | ); 38 | }; 39 | 40 | export default CommunityAuthor; 41 | -------------------------------------------------------------------------------- /docs/src/components/theme/themeProvider.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming'; 3 | import { Global } from '@emotion/core'; 4 | 5 | import { lightTheme, darkTheme } from './index'; 6 | import Header from '../Header'; 7 | import { baseStyles } from '../styles/GlobalStyles'; 8 | 9 | class ThemeProvider extends React.Component { 10 | state = { 11 | isDarkThemeActive: false, 12 | }; 13 | 14 | componentDidMount() { 15 | this.retrieveActiveTheme(); 16 | } 17 | 18 | retrieveActiveTheme = () => { 19 | const isDarkThemeActive = JSON.parse(window.localStorage.getItem('isDarkThemeActive')); 20 | 21 | this.setState({ isDarkThemeActive }); 22 | }; 23 | 24 | toggleActiveTheme = () => { 25 | this.setState(prevState => ({ isDarkThemeActive: !prevState.isDarkThemeActive })); 26 | 27 | window.localStorage.setItem('isDarkThemeActive', JSON.stringify(!this.state.isDarkThemeActive)); 28 | }; 29 | 30 | render() { 31 | const { children, location } = this.props; 32 | 33 | const { isDarkThemeActive } = this.state; 34 | 35 | const currentActiveTheme = isDarkThemeActive ? darkTheme : lightTheme; 36 | 37 | return ( 38 |
39 | 40 |
45 | {children} 46 |
47 | ); 48 | } 49 | } 50 | 51 | export default ThemeProvider; 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "action-slack", 3 | "version": "3.8.0", 4 | "description": "You can notify slack of GitHub Actions.", 5 | "main": "lib/main.js", 6 | "scripts": { 7 | "build": "tsc", 8 | "format": "prettier --write **/*.ts", 9 | "format-check": "prettier --check **/*.ts", 10 | "lint": "eslint src/**/*.ts", 11 | "pack": "ncc build -m", 12 | "test": "jest && codecov", 13 | "test-for-local": "jest", 14 | "all": "npm run build && npm run format-check && npm run lint && npm run pack && npm test", 15 | "release": "npm run build && npm run pack", 16 | "prepare-release": "./scripts/prepare-release.sh" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/8398a7/action-slack.git" 21 | }, 22 | "keywords": [ 23 | "actions", 24 | "node", 25 | "setup", 26 | "chat", 27 | "slack" 28 | ], 29 | "author": "8398a7", 30 | "license": "MIT", 31 | "dependencies": { 32 | "@actions/core": "^1.2.6", 33 | "@actions/github": "^4.0.0", 34 | "@slack/webhook": "^5.0.3", 35 | "semver": "^7.3.2" 36 | }, 37 | "devDependencies": { 38 | "@types/jest": "^26.0.9", 39 | "@types/node": "^14.0.27", 40 | "@types/semver": "^7.3.1", 41 | "@typescript-eslint/parser": "^3.8.0", 42 | "@zeit/ncc": "^0.22.3", 43 | "codecov": "^3.7.2", 44 | "eslint": "^7.6.0", 45 | "eslint-plugin-github": "^4.1.1", 46 | "eslint-plugin-jest": "^23.20.0", 47 | "jest": "^26.2.2", 48 | "jest-circus": "^26.2.2", 49 | "js-yaml": "^3.14.0", 50 | "nock": "^13.0.3", 51 | "prettier": "^2.0.5", 52 | "ts-jest": "^26.1.4", 53 | "typescript": "^3.9.7" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /docs/src/components/sidebar/treeNode.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import OpenedSvg from '../images/opened'; 3 | import ClosedSvg from '../images/closed'; 4 | import config from '../../../config'; 5 | import Link from '../link'; 6 | 7 | const TreeNode = ({ className = '', setCollapsed, collapsed, url, title, items, ...rest }) => { 8 | const isCollapsed = collapsed[url]; 9 | 10 | const collapse = () => { 11 | setCollapsed(url); 12 | }; 13 | 14 | const hasChildren = items.length !== 0; 15 | 16 | let location; 17 | 18 | if (typeof document != 'undefined') { 19 | location = document.location; 20 | } 21 | const active = 22 | location && (location.pathname === url || location.pathname === config.gatsby.pathPrefix + url); 23 | 24 | const calculatedClassName = `${className} item ${active ? 'active' : ''}`; 25 | 26 | return ( 27 |
  • 28 | {title && ( 29 | 30 | {title} 31 | {!config.sidebar.frontLine && title && hasChildren ? ( 32 | 35 | ) : null} 36 | 37 | )} 38 | 39 | {!isCollapsed && hasChildren ? ( 40 |
      41 | {items.map((item, index) => ( 42 | 48 | ))} 49 |
    50 | ) : null} 51 |
  • 52 | ); 53 | }; 54 | 55 | export default TreeNode; 56 | -------------------------------------------------------------------------------- /__tests__/matrix.test.ts: -------------------------------------------------------------------------------- 1 | import nock from 'nock'; 2 | 3 | process.env.GITHUB_RUN_ID = '2'; 4 | process.env.MATRIX_CONTEXT = '{"os": "ubuntu-18.04"}'; 5 | 6 | import { 7 | githubToken, 8 | newWith, 9 | setupNockCommit, 10 | setupNockJobs, 11 | successMsg, 12 | } from './helper'; 13 | import { Client, With, Success } from '../src/client'; 14 | 15 | beforeAll(() => { 16 | nock.disableNetConnect(); 17 | setupNockCommit(process.env.GITHUB_SHA as string); 18 | setupNockJobs( 19 | process.env.GITHUB_RUN_ID as string, 20 | 'actions.matrix-runs.jobs', 21 | ); 22 | }); 23 | afterAll(() => { 24 | nock.cleanAll(); 25 | nock.enableNetConnect(); 26 | }); 27 | 28 | describe('MATRIX_CONTEXT', () => { 29 | beforeEach(() => { 30 | process.env.GITHUB_REPOSITORY = '8398a7/action-slack'; 31 | process.env.GITHUB_EVENT_NAME = 'push'; 32 | const github = require('@actions/github'); 33 | github.context.payload = {}; 34 | }); 35 | 36 | it('runs in matrix', async () => { 37 | const withParams: With = { 38 | ...newWith(), 39 | status: Success, 40 | fields: 'job,took', 41 | }; 42 | const client = new Client(withParams, githubToken, ''); 43 | expect(await client.prepare('')).toStrictEqual({ 44 | text: successMsg, 45 | attachments: [ 46 | { 47 | author_name: '', 48 | color: 'good', 49 | fields: [ 50 | { 51 | short: true, 52 | title: 'job', 53 | value: 54 | '', 55 | }, 56 | { short: true, title: 'took', value: '1 hour 1 min 1 sec' }, 57 | ], 58 | }, 59 | ], 60 | username: '', 61 | icon_emoji: '', 62 | icon_url: '', 63 | channel: '', 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /docs/src/components/styles/Docs.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled'; 2 | 3 | export const StyledHeading = styled('h1')` 4 | font-size: 32px; 5 | line-height: 1.5; 6 | font-weight: 500; 7 | border-left: 2px solid #1ed3c6; 8 | padding: 0 16px; 9 | flex: 1; 10 | margin-top: 0; 11 | padding-top: 0; 12 | color: ${props => props.theme.colors.heading}; 13 | `; 14 | 15 | export const Edit = styled('div')` 16 | padding: 1rem 1.5rem; 17 | text-align: right; 18 | 19 | a { 20 | font-size: 14px; 21 | font-weight: 500; 22 | line-height: 1em; 23 | text-decoration: none; 24 | color: #555; 25 | border: 1px solid rgb(211, 220, 228); 26 | cursor: pointer; 27 | border-radius: 3px; 28 | transition: all 0.2s ease-out 0s; 29 | text-decoration: none; 30 | color: rgb(36, 42, 49); 31 | background-color: rgb(255, 255, 255); 32 | box-shadow: rgba(116, 129, 141, 0.1) 0px 1px 1px 0px; 33 | height: 30px; 34 | padding: 5px 16px; 35 | &:hover { 36 | background-color: rgb(245, 247, 249); 37 | } 38 | } 39 | `; 40 | 41 | export const StyledMainWrapper = styled.div` 42 | max-width: 750px; 43 | color: ${props => props.theme.colors.text}; 44 | 45 | ul, 46 | ol { 47 | -webkit-padding-start: 40px; 48 | -moz-padding-start: 40px; 49 | -o-padding-start: 40px; 50 | margin: 24px 0px; 51 | padding: 0px 0px 0px 2em; 52 | 53 | li { 54 | font-size: 16px; 55 | line-height: 1.8; 56 | font-weight: 400; 57 | } 58 | } 59 | 60 | a { 61 | transition: color 0.15s; 62 | color: ${props => props.theme.colors.link}; 63 | } 64 | 65 | code { 66 | border: 1px solid #ede7f3; 67 | border-radius: 4px; 68 | padding: 2px 6px; 69 | font-size: 0.9375em; 70 | 71 | background: ${props => props.theme.colors.background}; 72 | } 73 | 74 | @media (max-width: 767px) { 75 | padding: 0 15px; 76 | } 77 | `; 78 | -------------------------------------------------------------------------------- /__tests__/customJobName.test.ts: -------------------------------------------------------------------------------- 1 | import nock from 'nock'; 2 | 3 | process.env.GITHUB_RUN_ID = '2'; 4 | process.env.MATRIX_CONTEXT = '{"os": "ubuntu-18.04"}'; 5 | 6 | import { 7 | githubToken, 8 | newWith, 9 | setupNockCommit, 10 | setupNockJobs, 11 | successMsg, 12 | } from './helper'; 13 | import { Client, With, Success } from '../src/client'; 14 | 15 | beforeAll(() => { 16 | nock.disableNetConnect(); 17 | setupNockCommit(process.env.GITHUB_SHA as string); 18 | setupNockJobs( 19 | process.env.GITHUB_RUN_ID as string, 20 | 'actions.custom-job-name.jobs', 21 | ); 22 | }); 23 | afterAll(() => { 24 | nock.cleanAll(); 25 | nock.enableNetConnect(); 26 | }); 27 | 28 | describe('job_name', () => { 29 | beforeEach(() => { 30 | process.env.GITHUB_REPOSITORY = '8398a7/action-slack'; 31 | process.env.GITHUB_EVENT_NAME = 'push'; 32 | const github = require('@actions/github'); 33 | github.context.payload = {}; 34 | }); 35 | 36 | it('works even if you rename the job', async () => { 37 | const withParams: With = { 38 | ...newWith(), 39 | status: Success, 40 | fields: 'job,took', 41 | job_name: 'Custom Job', 42 | }; 43 | const client = new Client(withParams, githubToken, ''); 44 | expect(await client.prepare('')).toStrictEqual({ 45 | text: successMsg, 46 | attachments: [ 47 | { 48 | author_name: '', 49 | color: 'good', 50 | fields: [ 51 | { 52 | short: true, 53 | title: 'job', 54 | value: 55 | '', 56 | }, 57 | { short: true, title: 'took', value: '1 hour 1 min 1 sec' }, 58 | ], 59 | }, 60 | ], 61 | username: '', 62 | icon_emoji: '', 63 | icon_url: '', 64 | channel: '', 65 | }); 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directory 2 | node_modules 3 | 4 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | .env.test 71 | 72 | # parcel-bundler cache (https://parceljs.org/) 73 | .cache 74 | 75 | # next.js build output 76 | .next 77 | 78 | # nuxt.js build output 79 | .nuxt 80 | 81 | # vuepress build output 82 | .vuepress/dist 83 | 84 | # Serverless directories 85 | .serverless/ 86 | 87 | # FuseBox cache 88 | .fusebox/ 89 | 90 | # DynamoDB Local files 91 | .dynamodb/ 92 | 93 | # OS metadata 94 | .DS_Store 95 | Thumbs.db 96 | 97 | # Ignore built ts files 98 | __tests__/runner/* 99 | lib/**/* -------------------------------------------------------------------------------- /docs/config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | gatsby: { 3 | pathPrefix: '/', 4 | siteUrl: 'https://action-slack.netlify.app', 5 | gaTrackingId: null, 6 | trailingSlash: false, 7 | }, 8 | header: { 9 | logo: '', 10 | logoLink: '', 11 | title: 'action-slack', 12 | githubUrl: 'https://github.com/8398a7/action-slack', 13 | helpUrl: '', 14 | tweetText: '', 15 | twitter: '8398a7', 16 | links: [{ text: '', link: '' }], 17 | search: { 18 | enabled: true, 19 | indexName: process.env.ALGOLIA === 'dev' ? 'dev_action-slack' : 'prod_action-slack', 20 | algoliaAppId: process.env.GATSBY_ALGOLIA_APP_ID, 21 | algoliaSearchKey: process.env.GATSBY_ALGOLIA_SEARCH_KEY, 22 | algoliaAdminKey: process.env.ALGOLIA_ADMIN_KEY, 23 | }, 24 | }, 25 | sidebar: { 26 | forcedNavOrder: ['/usage', '/with', '/fields', '/migration', '/usecase', '/contributors'], 27 | collapsedNav: ['/usecase', '/migration'], 28 | links: [{ text: 'GitHub', link: 'https://github.com/8398a7/action-slack' }], 29 | frontline: false, 30 | ignoreIndex: true, 31 | title: '', 32 | }, 33 | siteMetadata: { 34 | title: 'action-slack | 8398a7', 35 | description: '', 36 | ogImage: null, 37 | docsLocation: 'https://github.com/8398a7/action-slack/tree/master/docs/content', 38 | favicon: 'This is the action-slack documentation site.', 39 | }, 40 | pwa: { 41 | enabled: false, // disabling this will also remove the existing service worker. 42 | manifest: { 43 | name: '8398a7@action-slack', 44 | short_name: 'action-slack', 45 | start_url: '/', 46 | background_color: '#6b37bf', 47 | theme_color: '#6b37bf', 48 | display: 'standalone', 49 | crossOrigin: 'use-credentials', 50 | icons: [ 51 | { 52 | src: 'src/pwa-512.png', 53 | sizes: `512x512`, 54 | type: `image/png`, 55 | }, 56 | ], 57 | }, 58 | }, 59 | }; 60 | 61 | module.exports = config; 62 | -------------------------------------------------------------------------------- /__tests__/incorrectMatrix.test.ts: -------------------------------------------------------------------------------- 1 | import nock from 'nock'; 2 | 3 | process.env.GITHUB_RUN_ID = '2'; 4 | process.env.MATRIX_CONTEXT = '{}'; 5 | 6 | import { 7 | githubToken, 8 | newWith, 9 | setupNockCommit, 10 | setupNockJobs, 11 | successMsg, 12 | } from './helper'; 13 | import { Client, With, Success } from '../src/client'; 14 | 15 | beforeAll(() => { 16 | nock.disableNetConnect(); 17 | setupNockCommit(process.env.GITHUB_SHA as string); 18 | setupNockJobs( 19 | process.env.GITHUB_RUN_ID as string, 20 | 'actions.matrix-runs.jobs', 21 | ); 22 | }); 23 | afterAll(() => { 24 | nock.cleanAll(); 25 | nock.enableNetConnect(); 26 | }); 27 | 28 | describe('MATRIX_CONTEXT', () => { 29 | beforeEach(() => { 30 | process.env.GITHUB_REPOSITORY = '8398a7/action-slack'; 31 | process.env.GITHUB_EVENT_NAME = 'push'; 32 | const github = require('@actions/github'); 33 | github.context.payload = {}; 34 | }); 35 | 36 | it('not runs in matrix', async () => { 37 | const withParams = { 38 | ...newWith(), 39 | status: Success, 40 | fields: 'job,took', 41 | }; 42 | const client = new Client(withParams, githubToken, ''); 43 | expect(await client.prepare('')).toStrictEqual({ 44 | text: successMsg, 45 | attachments: [ 46 | { 47 | author_name: '', 48 | color: 'good', 49 | fields: [ 50 | { 51 | short: true, 52 | title: 'job', 53 | value: 54 | 'Job is not found.\nCheck or .', 55 | }, 56 | { 57 | short: true, 58 | title: 'took', 59 | value: 60 | 'Job is not found.\nCheck or .', 61 | }, 62 | ], 63 | }, 64 | ], 65 | username: '', 66 | icon_emoji: '', 67 | icon_url: '', 68 | channel: '', 69 | }); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # action-slack 2 | 3 | ![](https://github.com/8398a7/action-slack/workflows/test-build/badge.svg) 4 | ![](https://github.com/8398a7/action-slack/workflows/Slack%20Mainline/badge.svg) 5 | ![](https://img.shields.io/github/license/8398a7/action-slack?color=brightgreen) 6 | ![](https://img.shields.io/github/v/release/8398a7/action-slack?color=brightgreen) 7 | [![codecov](https://codecov.io/gh/8398a7/action-slack/branch/master/graph/badge.svg)](https://codecov.io/gh/8398a7/action-slack) 8 | 9 | - [Document](https://action-slack.netlify.app) 10 | 11 | ## Quick Start 12 | 13 | You can learn more about it [here](https://action-slack.netlify.app/usecase/01-general). 14 | 15 | ```yaml 16 | steps: 17 | - uses: 8398a7/action-slack@v3 18 | with: 19 | status: ${{ job.status }} 20 | fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message) 21 | env: 22 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required 23 | if: always() # Pick up events even if the job fails or is canceled. 24 | ``` 25 | 26 | success 27 | 28 | ## Custom Formats of your choice 29 | 30 | You can learn more about it [here](https://action-slack.netlify.app/usecase/02-custom). 31 | 32 | ```yaml 33 | steps: 34 | - uses: 8398a7/action-slack@v3 35 | with: 36 | status: custom 37 | fields: workflow,job,commit,repo,ref,author,took 38 | custom_payload: | 39 | { 40 | username: 'action-slack', 41 | icon_emoji: ':octocat:', 42 | attachments: [{ 43 | color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', 44 | text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} succeeded in ${process.env.AS_TOOK}`, 45 | }] 46 | } 47 | env: 48 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 49 | ``` 50 | 51 | custom 52 | -------------------------------------------------------------------------------- /docs/src/html.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import config from '../config'; 4 | 5 | export default class HTML extends React.Component { 6 | render() { 7 | return ( 8 | 9 | 10 | 11 | 12 | 13 | {config.siteMetadata.ogImage ? ( 14 | 15 | ) : null} 16 | 17 | {config.siteMetadata.ogImage ? ( 18 | 19 | ) : null} 20 | {config.siteMetadata.favicon ? ( 21 | 22 | ) : null} 23 | 24 | {this.props.headComponents} 25 | 26 | 27 | {this.props.preBodyComponents} 28 |
    29 | {this.props.postBodyComponents} 30 |