-
Notifications
You must be signed in to change notification settings - Fork 7
103 lines (89 loc) · 3.49 KB
/
Copy pathmain.yml
File metadata and controls
103 lines (89 loc) · 3.49 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
98
99
100
101
102
103
name: Build
on:
push:
pull_request:
workflow_dispatch:
env:
GO111MODULE: on
jobs:
tests:
name: tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: true
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.13'
- name: Start MongoDB v4.2.0
uses: supercharge/mongodb-github-action@1.2.0
with:
mongodb-version: 4.2
- name: Start Redis
uses: supercharge/redis-github-action@1.2.0
- name: tests
env:
AUTHONE_DATABASE_USER: travis
AUTHONE_DATABASE_PASSWORD: test
run: |
mongo auth-one --eval 'db.createUser({user:"travis",pwd:"test",roles:["readWrite"]});'
go test ./... -coverprofile=coverage.out -covermode=atomic -p=1
#- name: publish codecov
# run: bash <(curl -s https://codecov.io/bash)
deploy-tst:
env:
JENKINS_AUTH_TOKEN: ${{ secrets.JENKINS_AUTH_TOKEN }}
JENKINS_BUILD_TOKEN: ${{ secrets.JENKINS_BUILD_TOKEN }}
needs: tests
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/master') && github.event_name == 'push'
steps:
- name: Deploy to tst
run: |
docker run -e JENKINS_AUTH_TOKEN=$JENKINS_AUTH_TOKEN -e JENKINS_BUILD_TOKEN=$JENKINS_BUILD_TOKEN \
-e JENKINS_BUILD_PROJECT=$GITHUB_REPOSITORY -e JENKINS_BUILD_BRANCH=${GITHUB_REF##*/} p1hub/p1jenkinstrigger
# deploy-stg-releasebranch:
# env:
# JENKINS_AUTH_TOKEN: ${{ secrets.JENKINS_AUTH_TOKEN }}
# JENKINS_BUILD_TOKEN: ${{ secrets.JENKINS_BUILD_TOKEN }}
# needs: tests
# runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/heads/release') && github.event_name == 'push'
# steps:
# - name: Deploy release branch to stg
# run: |
# docker run -e JENKINS_AUTH_TOKEN=$JENKINS_AUTH_TOKEN -e JENKINS_BUILD_TOKEN=$JENKINS_BUILD_TOKEN \
# -e JENKINS_BUILD_PROJECT=$GITHUB_REPOSITORY -e JENKINS_BUILD_BRANCH=${GITHUB_REF#refs/heads/} -e DEPLOY_TO_ENV="stg" -e IS_RB="true" p1hub/p1jenkinstrigger
# deploy-stg-tag:
# env:
# JENKINS_AUTH_TOKEN: ${{ secrets.JENKINS_AUTH_TOKEN }}
# JENKINS_BUILD_TOKEN: ${{ secrets.JENKINS_BUILD_TOKEN }}
# needs: tests
# runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push'
# steps:
# - name: Deploy release tag to stg
# run: |
# docker run -e JENKINS_AUTH_TOKEN=$JENKINS_AUTH_TOKEN -e JENKINS_BUILD_TOKEN=$JENKINS_BUILD_TOKEN \
# -e JENKINS_BUILD_PROJECT=$GITHUB_REPOSITORY -e JENKINS_BUILD_BRANCH=${GITHUB_REF##*/} -e DEPLOY_TO_ENV="stg" p1hub/p1jenkinstrigger
slack-notification:
#needs: [tests, deploy-tst, deploy-stg-releasebranch, deploy-stg-tag]
needs: [tests, deploy-tst]
runs-on: ubuntu-latest
if: always()
steps:
- name: Slack Workflow Notification
uses: paysuper/slack-workflow-status@118b3b43993d447a1a5cd7fddf5a1235ab219b18
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}