Skip to content

Commit 229e4dc

Browse files
committed
add template files
1 parent badffdd commit 229e4dc

File tree

24 files changed

+2917
-137
lines changed

24 files changed

+2917
-137
lines changed

.github/actions/build/action.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Build'
2+
description: 'Download the install artifacts and build the project'
3+
branding:
4+
icon: 'settings'
5+
color: 'green'
6+
7+
inputs:
8+
branch-name:
9+
description: 'Branch name'
10+
required: true
11+
slack-web-hook:
12+
description: 'Slack WebHook URL'
13+
required: true
14+
slack-channel-name:
15+
description: 'Slack channel name'
16+
required: true
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: 'Use Node.js ${{ matrix.node-version }}'
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '${{ matrix.node-version }}'
25+
cache: 'yarn'
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: yarn install
30+
31+
- name: yarn build
32+
shell: bash
33+
run: yarn build
34+
env:
35+
DATABASE_URL: ${{ inputs.database-url }}
36+
37+
- name: Notify Slack on Success
38+
if: ${{ success() }}
39+
uses: ./.github/actions/slack-notifier
40+
with:
41+
action-status: ${{ job.status }}
42+
slack-web-hook: ${{ inputs.slack-web-hook }}
43+
slack-channel-name: ${{ inputs.slack-channel-name }}
44+
title: 'Build Success :pass:'
45+
message: 'Build on ${{ inputs.branch-name }} succeeded :pass: :fireparrot: :sheepy:'
46+
47+
- name: Notify Slack on Failure
48+
if: ${{ failure() }}
49+
uses: ./.github/actions/slack-notifier
50+
with:
51+
action-status: ${{ job.status }}
52+
slack-web-hook: ${{ inputs.slack-web-hook }}
53+
slack-channel-name: ${{ inputs.slack-channel-name }}
54+
title: 'Build Failed :fail:'
55+
message: 'Build on ${{ inputs.branch-name }} failed :fail: :terror: :alert:'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Create Pull Request'
2+
description: 'Create a pull request from a feature branch to master'
3+
inputs:
4+
pat:
5+
description: 'GitHub PAT'
6+
required: true
7+
slack-web-hook:
8+
description: 'Slack WebHook URL'
9+
required: true
10+
slack-channel-name:
11+
description: 'Slack channel name'
12+
required: true
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- name: Get branch name
18+
id: branch-name
19+
uses: tj-actions/branch-names@v6
20+
21+
- name: Create Pull Request
22+
uses: devops-infra/action-pull-request@v0.5.0
23+
with:
24+
github_token: ${{ inputs.pat }}
25+
source_branch: '${{ steps.branch-name.outputs.current_branch }}'
26+
target_branch: master
27+
title: 'Merge ${{ steps.branch-name.outputs.current_branch }} to master'
28+
body: '**Automated pull request**'
29+
assignee: ${{ github.actor }}
30+
draft: false
31+
allow_no_diff: false
32+
get_diff: true
33+
34+
- name: Notify Slack on Success
35+
if: ${{ success() }}
36+
uses: ./.github/actions/slack-notifier
37+
with:
38+
action-status: ${{ job.status }}
39+
slack-web-hook: ${{ inputs.slack-web-hook }}
40+
slack-channel-name: ${{ inputs.slack-channel-name }}
41+
title: 'Create PR Success :pass:'
42+
message: 'Create PR on ${{ inputs.branch-name }} succeeded :pass: :fireparrot: :sheepy:'
43+
44+
- name: Notify Slack on Failure
45+
if: ${{ failure() }}
46+
uses: ./.github/actions/slack-notifier
47+
with:
48+
action-status: ${{ job.status }}
49+
slack-web-hook: ${{ inputs.slack-web-hook }}
50+
slack-channel-name: ${{ inputs.slack-channel-name }}
51+
title: 'Create PR Failed :fail:'
52+
message: 'Create PR on ${{ inputs.branch-name }} failed :fail: :terror: :alert:'

.github/actions/deploy/action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 'Deploy'
2+
description: 'Deploy the project to AWS Lambda'
3+
branding:
4+
icon: 'settings'
5+
color: 'green'
6+
7+
inputs:
8+
branch-name:
9+
description: 'Branch name'
10+
required: true
11+
serverless-access-key:
12+
description: 'Serverless Access Key'
13+
required: true
14+
slack-web-hook:
15+
description: 'Slack WebHook URL'
16+
required: true
17+
slack-channel-name:
18+
description: 'Slack channel name'
19+
required: true
20+
21+
runs:
22+
using: 'composite'
23+
steps:
24+
- name: 'Use Node.js ${{ matrix.node-version }}'
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: '${{ matrix.node-version }}'
28+
29+
- name: Install Serverless
30+
shell: bash
31+
run: |
32+
yarn global add serverless@3.2.0
33+
34+
- name: Install dependencies
35+
shell: bash
36+
run: |
37+
yarn install
38+
39+
- name: Deploy to AWS Lambda
40+
shell: bash
41+
run: |
42+
serverless deploy --stage production --verbose
43+
env:
44+
SERVERLESS_ACCESS_KEY: ${{ inputs.serverless-access-key }}
45+
46+
- name: Notify Slack on Success
47+
if: ${{ success() }}
48+
uses: ./.github/actions/slack-notifier
49+
with:
50+
action-status: ${{ job.status }}
51+
slack-web-hook: ${{ inputs.slack-web-hook }}
52+
slack-channel-name: ${{ inputs.slack-channel-name }}
53+
title: 'Deploy Success :pass:'
54+
message: 'Deploy on ${{ inputs.branch-name }} succeeded :pass: :fireparrot: :sheepy:'
55+
56+
- name: Notify Slack on Failure
57+
if: ${{ failure() }}
58+
uses: ./.github/actions/slack-notifier
59+
with:
60+
action-status: ${{ job.status }}
61+
slack-web-hook: ${{ inputs.slack-web-hook }}
62+
slack-channel-name: ${{ inputs.slack-channel-name }}
63+
title: 'Deploy Failed :fail:'
64+
message: 'Deploy on ${{ inputs.branch-name }} failed :fail: :terror: :alert:'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Slack Notifications on GitHub Actions'
2+
description: 'Notify Slack channel on GitHub Actions'
3+
inputs:
4+
action-status:
5+
description: 'Status of the action. Can be Success, Failure'
6+
required: true
7+
slack-web-hook:
8+
description: 'Slack WebHook URL'
9+
required: true
10+
slack-channel-name:
11+
description: 'Slack channel name'
12+
required: true
13+
title:
14+
description: 'Title of the message'
15+
required: true
16+
message:
17+
description: 'Message'
18+
required: true
19+
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- name: Slack Notification
24+
uses: rtCamp/action-slack-notify@v2
25+
env:
26+
SLACK_CHANNEL: ${{ inputs.slack-channel-name }}
27+
SLACK_COLOR: ${{ inputs.action-status }}
28+
SLACK_ICON: 'https://your_custome_icon_url?size=48'
29+
SLACK_MESSAGE: ${{ inputs.message }}
30+
SLACK_TITLE: ${{ inputs.title }}
31+
SLACK_USERNAME: GitHubBot
32+
SLACK_WEBHOOK: ${{ inputs.slack-web-hook }}
33+
MSG_MINIMAL: event,actions url,commit

.github/actions/test/action.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 'Test'
2+
description: 'Download the install artifacts and run the tests'
3+
branding:
4+
icon: 'check-circle'
5+
color: 'green'
6+
7+
inputs:
8+
branch-name:
9+
description: 'Branch name'
10+
required: true
11+
slack-web-hook:
12+
description: 'Slack WebHook URL'
13+
required: true
14+
slack-channel-name:
15+
description: 'Slack channel name'
16+
required: true
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: 'Use Node.js ${{ matrix.node-version }}'
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '${{ matrix.node-version }}'
25+
cache: 'yarn'
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: yarn install
30+
31+
- name: yarn test
32+
shell: bash
33+
run: yarn test
34+
env:
35+
CI: true
36+
37+
- name: Notify Slack on Success
38+
if: ${{ success() }}
39+
uses: ./.github/actions/slack-notifier
40+
with:
41+
action-status: ${{ job.status }}
42+
slack-web-hook: ${{ inputs.slack-web-hook }}
43+
slack-channel-name: ${{ inputs.slack-channel-name }}
44+
title: 'Test Success :pass:'
45+
message: 'Test on ${{ inputs.branch-name }} succeeded :pass: :fireparrot: :sheepy:'
46+
47+
- name: Notify Slack on Failure
48+
if: ${{ failure() }}
49+
uses: ./.github/actions/slack-notifier
50+
with:
51+
action-status: ${{ job.status }}
52+
slack-web-hook: ${{ inputs.slack-web-hook }}
53+
slack-channel-name: ${{ inputs.slack-channel-name }}
54+
title: 'Test Failed :fail:'
55+
message: 'Test on ${{ inputs.branch-name }} failed :fail: :terror: :alert:'

.github/workflows/dev.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'Feature Branch Unit Test & Build & Create PR'
2+
3+
on:
4+
push:
5+
branches:
6+
- feature/*
7+
8+
jobs:
9+
test:
10+
name: Unit Test
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [ 16.x ]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Get branch name
22+
id: branch-name
23+
uses: tj-actions/branch-names@v6
24+
25+
- name: Test
26+
uses: ./.github/actions/test
27+
with:
28+
branch-name: '${{ steps.branch-name.outputs.current_branch }}'
29+
slack-web-hook: ${{ secrets.SLACK_WEBHOOK }}
30+
slack-channel-name: ${{ secrets.CHANNEL_NAME }}
31+
32+
build:
33+
name: Build
34+
needs: test
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
node-version: [ 16.x ]
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v3
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Get branch name
46+
id: branch-name
47+
uses: tj-actions/branch-names@v6
48+
49+
- name: Build
50+
uses: ./.github/actions/build
51+
with:
52+
branch-name: '${{ steps.branch-name.outputs.current_branch }}'
53+
slack-web-hook: ${{ secrets.SLACK_WEBHOOK }}
54+
slack-channel-name: ${{ secrets.CHANNEL_NAME }}
55+
56+
create-pr:
57+
name: Create PR
58+
needs: build
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v3
63+
with:
64+
fetch-depth: 0
65+
66+
- name: Create PR
67+
uses: ./.github/actions/create-pr
68+
with:
69+
pat: ${{ secrets.PAT }}
70+
slack-web-hook: ${{ secrets.SLACK_WEBHOOK }}
71+
slack-channel-name: ${{ secrets.CHANNEL_NAME }}

0 commit comments

Comments
 (0)