-
Notifications
You must be signed in to change notification settings - Fork 24
75 lines (73 loc) · 2.57 KB
/
build-and-deploy.yml
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
name: Build and Publish Marketplace
on:
push:
jobs:
build:
runs-on: ubuntu-22.04
container: cimg/go:1.19
defaults:
run:
shell: bash
steps:
- name: build/checkout-repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0
- name: build/ensure-master-exists
run: git rev-parse --verify master >/dev/null 2>&1 || git branch master origin/master
- name: build/check-style
run: make check-style
- name: build/test
run: make test
- name: build/build
run: make build
- name: build/check-uncommitted-changes
run: |
# Assert that 'git status --porcelain' does not produce output
[ -z "$(git status --porcelain)" ] || {
echo "ERROR: uncommitted changes"
git status --porcelain
exit 1
}
- name: build/persist-build
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: marketplace-build
path: dist/
retention-days: 2
deploy:
if: ${{ github.repository == 'mattermost/mattermost-marketplace' && (github.ref_name == 'master' || github.ref_name == 'production') }}
runs-on: ubuntu-22.04
container: node:20
needs:
- build
defaults:
run:
shell: bash
env:
AWS_DEFAULT_REGION: us-east-1
steps:
- name: build/checkout-repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: deploy/install-dependencies
run: npm i -g "serverless@<4.0.0"
- name: deploy/download-build
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: marketplace-build
path: dist/
# Required because of https://github.com/actions/upload-artifact/issues/38
- name: deploy/set-artifact-permissions
run: chmod +x dist/*
- name: deploy/master-branch
if: ${{ github.ref_name == 'master' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.MM_MARKETPLACE_AWS_ACCESS_KEY_ID_STAGING }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MM_MARKETPLACE_AWS_SECRET_ACCESS_KEY_STAGING }}
run: serverless deploy function -f server --stage staging --verbose
- name: deploy/production-branch
if: ${{ github.ref_name == 'production' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.MM_MARKETPLACE_AWS_ACCESS_KEY_ID_PRODUCTION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MM_MARKETPLACE_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
run: serverless deploy function -f server --stage production --verbose