generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 156
136 lines (121 loc) · 4.61 KB
/
cd.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: cd
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_run:
workflows:
- ci
types:
- completed
branches:
- master
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: "0"
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
cache: true
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: |
webapp/package-lock.json
e2e-tests/package-lock.json
- name: Install webapp npm deps
env:
NODE_ENV: development
run: |
set -e
cd webapp
npm install --ignore-scripts --no-save --legacy-peer-deps
- name: Building Plugin Bundle
run: make dist CGO_ENABLED=0
- name: Generating Release Notes
run: |
set -e
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Enhancements\n\n## Fixes\n" >> dist/release-notes.md
if [[ $(git tag -l | wc -l) -eq 1 ]]; then
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md
else
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md
fi
- name: Pesist build artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: dist
path: |
dist/*.tar.gz
dist/release-notes.md
retention-days: 5 ## No need to keep CI builds more than 5 days
deploy-ci:
runs-on: ubuntu-22.04
if: ${{ github.ref_name == 'master' }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz
- name: cd/rename-artifacts
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz s3://mattermost-plugins-ci/ci/ --acl public-read --cache-control no-cache
deploy-release:
runs-on: ubuntu-22.04
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: |
mv dist/*.tar.gz dist/playbooks-${GITHUB_REF_NAME}.tar.gz
- name: cd/rename-artifacts
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/playbooks-${GITHUB_REF_NAME}.tar.gz s3://mattermost-plugins-ci/release/ --acl public-read --cache-control no-cache
- uses: jnwng/github-app-installation-token-action@c54add4c02866dc41e106745ac6dcf5cdd6339e5
id: installationToken
with:
appId: 276366
installationId: 32621164
privateKey: ${{ secrets.UNIFIED_CI_PRIVATE_KEY }}
- name: cd/create-github-release
env:
GITHUB_TOKEN: ${{ steps.installationToken.outputs.token }}
run: |
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file dist/release-notes.md dist/*.tar.gz