-
Notifications
You must be signed in to change notification settings - Fork 78
142 lines (127 loc) · 4.85 KB
/
ci.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
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
137
138
139
140
141
142
name: Continuous Integration
on:
push:
pull_request:
jobs:
ci:
name: Preside CI
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[twgit] Init') && github.ref != 'refs/heads/stable'"
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: preside_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Setup flow variables
run: |
branch=${GITHUB_REF##*/}
publish=false
if [[ "{{ env.event.name }}" != "pull_request" ]] ; then
if [[ $branch == release-* ]] || [[ $branch == v* ]] || [[ $branch == demo-* ]] ; then
publish=true
fi
fi
echo "PUBLISH_PRESIDE=$publish" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install dependencies
uses: pixl8/github-action-box-install@v2
with:
verbose: true
force: true
- name: Run tests
uses: pixl8/github-action-box-test@v4
with:
boxjson_dir: /tests
test_dir: /tests
test_server_json: /tests/server-presidetests.json
output_file: /tests/test-results.txt
verbose: false
env:
PRESIDETEST_DB_PORT: ${{ job.services.mysql.ports[3306] }}
PRESIDETEST_DB_HOST: mysql
- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: test-results
path: tests/test-results.txt
- name: Build static assets with grunt
if: "env.PUBLISH_PRESIDE == 'true'"
shell: bash
run: |
cd ./system/assets &&
npm install &&
grunt all &&
rm -rf node_modules
- name: Generate release version number
if: "env.PUBLISH_PRESIDE == 'true'"
id: versiongen
uses: pixl8/github-action-twgit-release-version-generator@v1
with:
build_number_start: 8000
- name: Set release variables
if: "env.PUBLISH_PRESIDE == 'true'"
shell: bash
env:
RELEASE_VERSION: ${{ steps.versiongen.outputs.semver_release_string }}
IS_SNAPSHOT: ${{ steps.versiongen.outputs.semver_is_snapshot }}
run: |
ZIP_FILE_NAME=Preside-${RELEASE_VERSION/+/-}.zip
if [[ $RELEASE_VERSION == "0.0.0-DEMO"* ]] ; then
RELEASE_CATEGORY=demo
elif [[ "${IS_SNAPSHOT}" == "false" ]] ; then
RELEASE_CATEGORY=stable
else
RELEASE_CATEGORY="bleeding-edge"
fi
echo "RELEASE_CATEGORY=$RELEASE_CATEGORY" >> $GITHUB_ENV
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
echo "DOWNLOAD_LOCATION=https://downloads.preside.org/$RELEASE_CATEGORY/$ZIP_FILE_NAME" >> $GITHUB_ENV
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Prepare files for release
if: "env.PUBLISH_PRESIDE == 'true'"
shell: bash
run: |
echo '{ "version":"$RELEASE_VERSION" }' > version.json &&
echo 'Built on: $( date )' > "Preside-$RELEASE_VERSION-$RELEASE_CATEGORY.txt" &&
mv box.json.published box.json
- name: Inject version numbers
if: "env.PUBLISH_PRESIDE == 'true'"
uses: dominicwatson/github-action-envsubst@v1
with:
files: box.json version.json system/config/Config.cfc
- name: Zip up
if: "env.PUBLISH_PRESIDE == 'true'"
shell: bash
run: zip -rq $ZIP_FILE_NAME * --exclude jmimemagic.log --exclude=".*" --exclude="*.sh" --exclude="zanata.xml" --exclude="\tests/*" --exclude="\system/externals/lucee-spreadsheet/javaloader/*"
- name: Push to S3
if: "env.PUBLISH_PRESIDE == 'true'"
run: aws s3 cp --acl=public-read $ZIP_FILE_NAME s3://downloads.preside.org/${RELEASE_CATEGORY}/${ZIP_FILE_NAME}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'eu-west-2'
- name: Publish to forgebox
if: "env.PUBLISH_PRESIDE == 'true'"
uses: pixl8/github-action-box-publish@v3
with:
forgebox_user: pixl8
forgebox_pass: ${{ secrets.FORGEBOX_PASS }}
- name: Inform Slack of success
if: "env.PUBLISH_PRESIDE == 'true'"
uses: craftech-io/slack-action@v1
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Inform Slack of failure
if: "failure() && env.PUBLISH_PRESIDE == 'true'"
uses: craftech-io/slack-action@v1
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: failure