-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (87 loc) · 3.28 KB
/
Copy pathpr-action.yml
File metadata and controls
97 lines (87 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: pull_request
on:
pull_request:
branches:
- dev
- master
jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: vars
run: |
if [[ "$REF" =~ ^[0-9]+.[0-9]+.[0-9]+$ || "$REF" == "master" ]]; then
BRANCH=master
INFRA_BRANCH=master
GCP_ENV=production
GCP_PROJECT_ID=${{ secrets.PROD_CP_GCP_PROJECT_ID }}
elif [[ "$REF" =~ ^[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+$ || "$REF" != "master" ]]; then
BRANCH=dev
INFRA_BRANCH=develop
GCP_ENV=develop
GCP_PROJECT_ID=${{ secrets.DEV_CP_GCP_PROJECT_ID }}
else
echo "Invalid tag format: $REF"
exit 1
fi
cat <<- EOF >> ${GITHUB_ENV}
BRANCH=${BRANCH}
GCP_ENV=${GCP_ENV}
GCP_PROJECT_ID=${GCP_PROJECT_ID}
IMAGE_NAME=gcr.io/${GCP_PROJECT_ID}/${GITHUB_REPOSITORY##*/}
IMAGE_TAG_SHA=${GITHUB_SHA:0:7}
EOF
- name: build_image_test
run: |
docker build -f Dockerfile.test -t ${IMAGE_NAME}:${IMAGE_TAG_SHA}-pr `pwd`
- name: unit_test
run: |
docker run --rm --entrypoint=npm ${IMAGE_NAME}:${IMAGE_TAG_SHA}-pr test
notify:
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- unit_test
steps:
- uses: technote-space/workflow-conclusion-action@v3.0.3
if: ${{ ! env.ACT }}
- name: vars
id: vars
run: |
STATUS=${WORKFLOW_CONCLUSION:-failure} # neutral, success, skipped, cancelled, timed_out, action_required, failure
if [[ ${STATUS} == "success" ]]; then
ICON_EMOJI=":white_check_mark:"
elif [[ ${STATUS} == "failure" ]]; then
ICON_EMOJI=":sos:"
else
ICON_EMOJI=":eyes:"
fi
MESSAGE=" ${ICON_EMOJI} \`dev\` \`${STATUS}\` @${{ github.actor }}
this is message"
FOOTER="this is footer"
if [[ "${{ ! env.ACT }}" == "true" ]]; then
STATUS=${{ env.WORKFLOW_CONCLUSION }}
if [[ "push" == "${{ github.event_name }}" ]]; then
MESSAGE=" ${ICON_EMOJI} \`${{ github.ref_name }}\` \`${STATUS}\`
${{ github.event.head_commit.message }}"
FOOTER="*${{ github.ref_name }}* of _${{ github.repository }}_"
elif [[ "pull_request" == "${{ github.event_name }}" ]]; then
MESSAGE=" ${ICON_EMOJI} \`${{ github.base_ref }}\` \`${STATUS}\`
${{ github.event.pull_request.title }}"
FOOTER="*${{ github.head_ref }}* of _${{ github.repository }}_"
fi
fi
echo "message=${MESSAGE//$'\n'/'%0A'}" >> $GITHUB_OUTPUT
echo "footer=${FOOTER}" >> $GITHUB_OUTPUT
echo "status=${STATUS}" >> $GITHUB_OUTPUT
- name: slack_notification
uses: rtCamp/action-slack-notify@v2.3.0
env:
SLACK_WEBHOOK: ${{ secrets.CP_SLACK_CHANNEL_RG_CRYPTO }}
SLACK_USERNAME: Github Action
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_COLOR: ${{ steps.vars.outputs.status }}
SLACK_MESSAGE: ${{ steps.vars.outputs.message }}
SLACK_FOOTER: ${{ steps.vars.outputs.footer }}
SLACK_LINK_NAMES: true