├── .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 | 7 | ); 8 | 9 | export default ClosedSvg; 10 | -------------------------------------------------------------------------------- /docs/src/components/images/opened.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const OpenedSvg = () => ( 4 | 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 |
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 |
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 |
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 |
45 |
46 |
47 | );
48 | }
49 | }
50 |
51 | HTML.propTypes = {
52 | htmlAttributes: PropTypes.object,
53 | headComponents: PropTypes.array,
54 | bodyAttributes: PropTypes.object,
55 | preBodyComponents: PropTypes.array,
56 | body: PropTypes.string,
57 | postBodyComponents: PropTypes.array,
58 | };
59 |
--------------------------------------------------------------------------------
/docs/src/components/rightSidebar.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { StaticQuery, graphql } from 'gatsby';
3 |
4 | // import Link from './link';
5 | import config from '../../config';
6 | import { Sidebar, ListItem } from './styles/Sidebar';
7 |
8 | const SidebarLayout = ({ location }) => (
9 |
26 |
27 | | Field | Environment Variable | Description |
28 | | --------- | ----------------------- | ------------------------------------------------------------ |
29 | | repo | `AS_REPO` | A working repository name |
30 | | commit | `AS_COMMIT` | commit hash |
31 | | eventName | `AS_EVENT_NAME` | trigger event name |
32 | | ref | `AS_REF` | git refrence |
33 | | workflow | `AS_WORKFLOW` | GitHub Actions workflow name |
34 | | action | `AS_ACTION` | Generate a workflow link from git sha |
35 | | message | `AS_MESSAGE` | commit message |
36 | | author | `AS_AUTHOR` | The author who pushed |
37 | | job | `AS_JOB` | The name of the job that was executed |
38 | | took | `AS_TOOK` | Execution time for the job |
39 |
40 | caution: The Field in `action` is similar to what you get in workflow. It will be removed in the next major release version.
41 |
42 | ```yaml
43 | steps:
44 | - uses: 8398a7/action-slack@v3
45 | with:
46 | fields: repo,commit
47 | env:
48 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
49 | ```
50 |
51 | If you want all items, specify `all`.
52 |
53 | ```yaml
54 | steps:
55 | - uses: 8398a7/action-slack@v3
56 | with:
57 | fields: all
58 | env:
59 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
60 | ```
61 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "action-slack-docs",
3 | "description": "Documentation, built with mdx",
4 | "author": "839 <8398a7@gmail.com> (@8398a7)",
5 | "version": "1.0.0",
6 | "dependencies": {
7 | "@babel/plugin-proposal-export-default-from": "^7.10.1",
8 | "@emotion/core": "^10.0.28",
9 | "@emotion/styled": "^10.0.27",
10 | "@emotion/styled-base": "^10.0.31",
11 | "@mdx-js/loader": "^1.6.6",
12 | "@mdx-js/mdx": "^1.6.6",
13 | "@mdx-js/react": "^1.6.6",
14 | "@philpl/buble": "^0.19.7",
15 | "@playlyfe/gql": "^2.6.2",
16 | "algoliasearch": "^3.35.1",
17 | "dotenv": "^8.2.0",
18 | "emotion": "^10.0.27",
19 | "emotion-server": "^10.0.27",
20 | "emotion-theming": "^10.0.27",
21 | "gatsby": "^2.23.11",
22 | "gatsby-link": "^2.4.8",
23 | "gatsby-plugin-algolia": "^0.5.0",
24 | "gatsby-plugin-emotion": "^4.3.6",
25 | "gatsby-plugin-gtag": "^1.0.13",
26 | "gatsby-plugin-layout": "^1.3.6",
27 | "gatsby-plugin-manifest": "^2.4.14",
28 | "gatsby-plugin-mdx": "^1.2.18",
29 | "gatsby-plugin-offline": "^3.2.13",
30 | "gatsby-plugin-react-helmet": "^3.3.6",
31 | "gatsby-plugin-remove-serviceworker": "^1.0.0",
32 | "gatsby-plugin-sharp": "^2.6.14",
33 | "gatsby-plugin-sitemap": "^2.4.7",
34 | "gatsby-remark-copy-linked-files": "^2.3.7",
35 | "gatsby-remark-images": "^3.3.13",
36 | "gatsby-source-filesystem": "^2.3.14",
37 | "gatsby-transformer-remark": "^2.8.19",
38 | "graphql": "^14.6.0",
39 | "is-absolute-url": "^3.0.3",
40 | "lodash.flatten": "^4.4.0",
41 | "lodash.startcase": "^4.4.0",
42 | "react": "^16.13.1",
43 | "react-dom": "^16.13.1",
44 | "react-feather": "^2.0.8",
45 | "react-github-btn": "^1.2.0",
46 | "react-helmet": "^5.2.1",
47 | "react-id-generator": "^3.0.0",
48 | "react-instantsearch-dom": "^6.6.0",
49 | "react-live": "^2.2.2",
50 | "react-loadable": "^5.5.0",
51 | "styled-components": "^4.4.1",
52 | "styled-icons": "^9.5.0"
53 | },
54 | "license": "MIT",
55 | "main": "n/a",
56 | "scripts": {
57 | "start": "gatsby develop",
58 | "build": "gatsby build --prefix-paths",
59 | "format": "prettier --write \"src/**/*.{js,jsx,css,json}\"",
60 | "lint": "eslint --fix \"src/**/*.{js,jsx}\""
61 | },
62 | "devDependencies": {
63 | "babel-eslint": "^10.1.0",
64 | "eslint": "^6.8.0",
65 | "eslint-config-prettier": "^6.11.0",
66 | "eslint-plugin-import": "^2.22.0",
67 | "eslint-plugin-jsx-a11y": "^6.3.1",
68 | "eslint-plugin-prettier": "^3.1.4",
69 | "eslint-plugin-react": "^7.20.0",
70 | "gatsby-plugin-remove-trailing-slashes": "^2.3.7",
71 | "prettier": "^1.19.1",
72 | "prism-react-renderer": "^1.1.1"
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/docs/src/components/styles/PageNavigationButtons.js:
--------------------------------------------------------------------------------
1 | import styled from '@emotion/styled';
2 |
3 | export const StyledNextPrevious = styled('div')`
4 | margin: 0px;
5 | padding: 0px;
6 | width: auto;
7 | display: grid;
8 | grid-template-rows: auto;
9 | column-gap: 24px;
10 | grid-template-columns: calc(50% - 8px) calc(50% - 8px);
11 |
12 | .previousBtn {
13 | cursor: pointer;
14 | -moz-box-align: center;
15 | -moz-box-direction: normal;
16 | -moz-box-orient: horizontal;
17 | margin: 0px;
18 | padding: 0px;
19 | position: relative;
20 | display: flex;
21 | flex-direction: row;
22 | align-items: center;
23 | place-self: stretch;
24 | border-radius: 3px;
25 | border: 1px solid rgb(230, 236, 241);
26 | transition: border 200ms ease 0s;
27 | box-shadow: rgba(116, 129, 141, 0.1) 0px 3px 8px 0px;
28 | text-decoration: none;
29 |
30 | background-color: ${props => props.theme.colors.background};
31 | color: ${props => props.theme.colors.text};
32 | }
33 |
34 | .nextBtn {
35 | cursor: pointer;
36 | -moz-box-align: center;
37 | -moz-box-direction: normal;
38 | -moz-box-orient: horizontal;
39 | margin: 0px;
40 | padding: 0px;
41 | position: relative;
42 | display: flex;
43 | flex-direction: row;
44 | align-items: center;
45 | place-self: stretch;
46 | border-radius: 3px;
47 | border: 1px solid rgb(230, 236, 241);
48 | transition: border 200ms ease 0s;
49 | box-shadow: rgba(116, 129, 141, 0.1) 0px 3px 8px 0px;
50 | text-decoration: none;
51 |
52 | background-color: ${props => props.theme.colors.background};
53 | color: ${props => props.theme.colors.text};
54 | }
55 |
56 | .nextBtn:hover,
57 | .previousBtn:hover {
58 | text-decoration: none;
59 | border: 1px solid #1ed3c6;
60 | }
61 |
62 | .nextBtn:hover .rightArrow,
63 | .previousBtn:hover .leftArrow {
64 | color: #1ed3c6;
65 | }
66 |
67 | .leftArrow {
68 | display: block;
69 | margin: 0px;
70 | color: rgb(157, 170, 182);
71 | flex: 0 0 auto;
72 | font-size: 24px;
73 | transition: color 200ms ease 0s;
74 | padding: 16px;
75 | padding-right: 16px;
76 | }
77 |
78 | .rightArrow {
79 | flex: 0 0 auto;
80 | font-size: 24px;
81 | transition: color 200ms ease 0s;
82 | padding: 16px;
83 | padding-left: 16px;
84 | display: block;
85 | margin: 0px;
86 | color: rgb(157, 170, 182);
87 | }
88 |
89 | .nextPreviousTitle {
90 | display: block;
91 | margin: 0px;
92 | padding: 0px;
93 | transition: color 200ms ease 0s;
94 | }
95 |
96 | .nextPreviousTitle span {
97 | font-size: 16px;
98 | line-height: 1.5;
99 | font-weight: 500;
100 | }
101 |
102 | @media (max-width: 767px) {
103 | display: block;
104 | padding: 0 15px;
105 |
106 | .previousBtn {
107 | margin-bottom: 20px;
108 | }
109 | }
110 | `;
111 |
--------------------------------------------------------------------------------
/docs/gatsby-node.js:
--------------------------------------------------------------------------------
1 | const componentWithMDXScope = require('gatsby-plugin-mdx/component-with-mdx-scope');
2 |
3 | const path = require('path');
4 |
5 | const startCase = require('lodash.startcase');
6 |
7 | const config = require('./config');
8 |
9 | exports.createPages = ({ graphql, actions }) => {
10 | const { createPage } = actions;
11 |
12 | return new Promise((resolve, reject) => {
13 | resolve(
14 | graphql(
15 | `
16 | {
17 | allMdx {
18 | edges {
19 | node {
20 | fields {
21 | id
22 | }
23 | tableOfContents
24 | fields {
25 | slug
26 | }
27 | }
28 | }
29 | }
30 | }
31 | `
32 | ).then(result => {
33 | if (result.errors) {
34 | console.log(result.errors); // eslint-disable-line no-console
35 | reject(result.errors);
36 | }
37 |
38 | // Create blog posts pages.
39 | result.data.allMdx.edges.forEach(({ node }) => {
40 | createPage({
41 | path: node.fields.slug ? node.fields.slug : '/',
42 | component: path.resolve('./src/templates/docs.js'),
43 | context: {
44 | id: node.fields.id,
45 | },
46 | });
47 | });
48 | })
49 | );
50 | });
51 | };
52 |
53 | exports.onCreateWebpackConfig = ({ actions }) => {
54 | actions.setWebpackConfig({
55 | resolve: {
56 | modules: [path.resolve(__dirname, 'src'), 'node_modules'],
57 | alias: {
58 | $components: path.resolve(__dirname, 'src/components'),
59 | buble: '@philpl/buble', // to reduce bundle size
60 | },
61 | },
62 | });
63 | };
64 |
65 | exports.onCreateBabelConfig = ({ actions }) => {
66 | actions.setBabelPlugin({
67 | name: '@babel/plugin-proposal-export-default-from',
68 | });
69 | };
70 |
71 | exports.onCreateNode = ({ node, getNode, actions }) => {
72 | const { createNodeField } = actions;
73 |
74 | if (node.internal.type === `Mdx`) {
75 | const parent = getNode(node.parent);
76 |
77 | let value = parent.relativePath.replace(parent.ext, '');
78 |
79 | if (value === 'index') {
80 | value = '';
81 | }
82 |
83 | if (config.gatsby && config.gatsby.trailingSlash) {
84 | createNodeField({
85 | name: `slug`,
86 | node,
87 | value: value === '' ? `/` : `/${value}/`,
88 | });
89 | } else {
90 | createNodeField({
91 | name: `slug`,
92 | node,
93 | value: `/${value}`,
94 | });
95 | }
96 |
97 | createNodeField({
98 | name: 'id',
99 | node,
100 | value: node.id,
101 | });
102 |
103 | createNodeField({
104 | name: 'title',
105 | node,
106 | value: node.frontmatter.title || startCase(parent.name),
107 | });
108 | }
109 | };
110 |
--------------------------------------------------------------------------------
/docs/content/usecase/02-custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Custom use case
3 | metaTitle: Custom use case | action-slack
4 | metaDescription: This describes the custom use case of action-slack.
5 | ---
6 |
7 | You will often want to send notifications in a format other than the one that action-slack has determined.
8 | In such a case, consider using `status: custom`.
9 |
10 | If you specify a payload in accordance with the slack specification, action-slack will notify you as it is.
11 | Use `status: custom` and [custom_payload](/with#custom_payload) to customize notifications to your liking can be sent.
12 |
13 | ```yaml
14 | steps:
15 | - uses: 8398a7/action-slack@v3
16 | with:
17 | status: custom
18 | custom_payload: |
19 | {
20 | text: "Custom Field Check",
21 | attachments: [{
22 | "author_name": "8398a7@action-slack", // json
23 | fallback: 'fallback',
24 | color: 'good',
25 | title: 'CI Result',
26 | text: 'Succeeded',
27 | fields: [{
28 | title: 'lower case',
29 | value: 'LOWER CASE CHECK'.toLowerCase(),
30 | short: true
31 | },
32 | {
33 | title: 'reverse',
34 | value: 'gnirts esrever'.split('').reverse().join(''),
35 | short: true
36 | },
37 | {
38 | title: 'long title1',
39 | value: 'long value1',
40 | short: false
41 | }],
42 | actions: [{
43 | }]
44 | }]
45 | }
46 | env:
47 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
48 | ```
49 |
50 | As you can see, the JavaScript functionality is available in the custom_payload . (e.g. `toLowerCase()`)
51 | We have even more options for those who want to use custom notifications, but want to use the Fields feature.
52 |
53 | ```yaml
54 | steps:
55 | - uses: 8398a7/action-slack@v3
56 | with:
57 | status: custom
58 | fields: workflow,job,commit,repo,ref,author,took
59 | custom_payload: |
60 | {
61 | username: 'action-slack',
62 | icon_emoji: ':octocat:',
63 | attachments: [{
64 | color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
65 | 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} ${{ job.status }} in ${process.env.AS_TOOK}`,
66 | }]
67 | }
68 | env:
69 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
70 | ```
71 |
72 | You can access the values retrieved by Fields through environment variables.
73 | See [Fields](/fields) for the available environment variables.
74 |
75 |
76 |
77 | If there's a good format, I'd like to introduce it on this page from time to time.
78 |
--------------------------------------------------------------------------------
/docs/gatsby-config.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config();
2 | const queries = require("./src/utils/algolia");
3 | const config = require("./config");
4 | const plugins = [
5 | 'gatsby-plugin-sitemap',
6 | 'gatsby-plugin-sharp',
7 | {
8 | resolve: `gatsby-plugin-layout`,
9 | options: {
10 | component: require.resolve(`./src/templates/docs.js`)
11 | }
12 | },
13 | 'gatsby-plugin-emotion',
14 | 'gatsby-plugin-react-helmet',
15 | {
16 | resolve: "gatsby-source-filesystem",
17 | options: {
18 | name: "docs",
19 | path: `${__dirname}/content/`
20 | }
21 | },
22 | {
23 | resolve: 'gatsby-plugin-mdx',
24 | options: {
25 | gatsbyRemarkPlugins: [
26 | {
27 | resolve: "gatsby-remark-images",
28 | options: {
29 | maxWidth: 1035,
30 | sizeByPixelDensity: true
31 | }
32 | },
33 | {
34 | resolve: 'gatsby-remark-copy-linked-files'
35 | }
36 | ],
37 | extensions: [".mdx", ".md"]
38 | }
39 | },
40 | {
41 | resolve: `gatsby-plugin-gtag`,
42 | options: {
43 | // your google analytics tracking id
44 | trackingId: config.gatsby.gaTrackingId,
45 | // Puts tracking script in the head instead of the body
46 | head: true,
47 | // enable ip anonymization
48 | anonymize: false,
49 | },
50 | },
51 | ];
52 | // check and add algolia
53 | if (config.header.search && config.header.search.enabled && config.header.search.algoliaAppId && config.header.search.algoliaAdminKey) {
54 | plugins.push({
55 | resolve: `gatsby-plugin-algolia`,
56 | options: {
57 | appId: config.header.search.algoliaAppId, // algolia application id
58 | apiKey: config.header.search.algoliaAdminKey, // algolia admin key to index
59 | queries,
60 | chunkSize: 10000, // default: 1000
61 | }}
62 | )
63 | }
64 | // check and add pwa functionality
65 | if (config.pwa && config.pwa.enabled && config.pwa.manifest) {
66 | plugins.push({
67 | resolve: `gatsby-plugin-manifest`,
68 | options: {...config.pwa.manifest},
69 | });
70 | plugins.push({
71 | resolve: 'gatsby-plugin-offline',
72 | options: {
73 | appendScript: require.resolve(`./src/custom-sw-code.js`),
74 | },
75 | });
76 | } else {
77 | plugins.push('gatsby-plugin-remove-serviceworker');
78 | }
79 |
80 | // check and remove trailing slash
81 | if (config.gatsby && !config.gatsby.trailingSlash) {
82 | plugins.push('gatsby-plugin-remove-trailing-slashes');
83 | }
84 |
85 | module.exports = {
86 | pathPrefix: config.gatsby.pathPrefix,
87 | siteMetadata: {
88 | title: config.siteMetadata.title,
89 | description: config.siteMetadata.description,
90 | docsLocation: config.siteMetadata.docsLocation,
91 | ogImage: config.siteMetadata.ogImage,
92 | favicon: config.siteMetadata.favicon,
93 | logo: { link: config.header.logoLink ? config.header.logoLink : '/', image: config.header.logo }, // backwards compatible
94 | headerTitle: config.header.title,
95 | githubUrl: config.header.githubUrl,
96 | helpUrl: config.header.helpUrl,
97 | tweetText: config.header.tweetText,
98 | headerLinks: config.header.links,
99 | siteUrl: config.gatsby.siteUrl,
100 | },
101 | plugins: plugins
102 | };
103 |
--------------------------------------------------------------------------------
/docs/src/components/sidebar/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Tree from './tree';
3 | import { StaticQuery, graphql } from 'gatsby';
4 | import styled from '@emotion/styled';
5 | import { ExternalLink } from 'react-feather';
6 | import config from '../../../config';
7 |
8 | // eslint-disable-next-line no-unused-vars
9 | const ListItem = styled(({ className, active, level, ...props }) => {
10 | return (
11 |
36 | {cleanTokens(tokens).map((line, i) => {
37 | let lineClass = {};
38 |
39 | let isDiff = false;
40 |
41 | if (line[0] && line[0].content.length && line[0].content[0] === '+') {
42 | lineClass = { backgroundColor: 'rgba(76, 175, 80, 0.2)' };
43 | isDiff = true;
44 | } else if (line[0] && line[0].content.length && line[0].content[0] === '-') {
45 | lineClass = { backgroundColor: 'rgba(244, 67, 54, 0.2)' };
46 | isDiff = true;
47 | } else if (line[0] && line[0].content === '' && line[1] && line[1].content === '+') {
48 | lineClass = { backgroundColor: 'rgba(76, 175, 80, 0.2)' };
49 | isDiff = true;
50 | } else if (line[0] && line[0].content === '' && line[1] && line[1].content === '-') {
51 | lineClass = { backgroundColor: 'rgba(244, 67, 54, 0.2)' };
52 | isDiff = true;
53 | }
54 | const lineProps = getLineProps({ line, key: i });
55 |
56 | lineProps.style = lineClass;
57 | const diffStyle = {
58 | userSelect: 'none',
59 | MozUserSelect: '-moz-none',
60 | WebkitUserSelect: 'none',
61 | };
62 |
63 | let splitToken;
64 |
65 | return (
66 |
67 | {line.map((token, key) => {
68 | if (isDiff) {
69 | if (
70 | (key === 0 || key === 1) &
71 | (token.content.charAt(0) === '+' || token.content.charAt(0) === '-')
72 | ) {
73 | if (token.content.length > 1) {
74 | splitToken = {
75 | types: ['template-string', 'string'],
76 | content: token.content.slice(1),
77 | };
78 | const firstChar = {
79 | types: ['operator'],
80 | content: token.content.charAt(0),
81 | };
82 |
83 | return (
84 |
85 |
89 |
90 |
91 | );
92 | } else {
93 | return ;
94 | }
95 | }
96 | }
97 | return ;
98 | })}
99 |
100 | );
101 | })}
102 |
103 | )}
104 |