-
Notifications
You must be signed in to change notification settings - Fork 10
162 lines (156 loc) · 5.62 KB
/
check_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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Run tests, dependency audit, CS fixer & deploy
on: [push]
jobs:
check:
name: Audit & code style checks
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Install dependencies (for CS fixer)
run: composer install
- name: Audit
run: composer audit
- name: Code Style
run: composer check
test:
name: Unit tests on PHP ${{ matrix.php-versions }}
needs: [ check ]
runs-on: ubuntu-20.04
strategy:
matrix:
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Install dependencies
run: composer install
- name: Test
run: composer test
build-zip-php-5:
name: Build the PHP 5.6 compatible ZIP
needs: [check, test]
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/') # only tags
steps:
- name: Get tag name
id: set-tag
run: echo "TAG_NAME=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Check out repository code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.6
- name: Build ZIP
run: ./release/build_release_package.sh
env:
TAG_NAME: ${{ steps.set-tag.outputs.TAG_NAME }}
PHP_VERSION: 'php-5.6'
- name: Store to cache
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-5.6.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-php-5
build-zip-php-7:
name: Build the PHP 7 & 8 compatible ZIP
needs: [check, test]
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/') # only tags
steps:
- name: Get tag name
id: set-tag
run: echo "TAG_NAME=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Check out repository code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.0
- name: Build ZIP
run: ./release/build_release_package.sh
env:
TAG_NAME: ${{ steps.set-tag.outputs.TAG_NAME }}
PHP_VERSION: 'php-7'
- name: Store to cache
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-7.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-php-7
release:
name: Create GitHub release & attach ZIP files
needs: [build-zip-php-5, build-zip-php-7]
if: startsWith(github.ref, 'refs/tags/') # only tags
runs-on: ubuntu-20.04
steps:
- name: Get tag name
id: set-tag
run: echo "TAG_NAME=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Load from cache (PHP 5)
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-5.6.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-php-5
- name: Load from cache (PHP 7 & 8)
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-7.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-php-7
- name: Release & upload
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.set-tag.outputs.TAG_NAME }}
name: Shopgate Cart Integration Shopware 5 ${{ steps.set-tag.outputs.TAG_NAME }}
draft: true
prerelease: true
fail_on_unmatched_files: true
files: |
./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-5.6.zip
./release/shopgate-shopware-integration-${{ steps.set-tag.outputs.TAG_NAME }}-php-7.zip
notify-release-success:
name: Notify developers of new release
needs: [release]
runs-on: ubuntu-20.04
if: |
success() &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Get tag name
id: set-tag
run: echo "TAG_NAME=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Notify on Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_MERCHANT_UNIT }}
SLACK_USERNAME: 'GitHub Actions'
SLACK_ICON_EMOJI: ':octocat:'
SLACK_TITLE: New release for ${{ github.repository }}
SLACK_MESSAGE: Released version ${{ steps.set-tag.outputs.TAG_NAME }} of ${{ github.repository }}
notify-release-fail:
name: Notify developers of failed release
needs: [release]
runs-on: ubuntu-20.04
if: |
failure() &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Get tag name
id: set-tag
run: echo "TAG_NAME=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
- name: Notify on Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_MERCHANT_UNIT }}
SLACK_USERNAME: 'GitHub Actions'
SLACK_ICON_EMOJI: ':octocat:'
SLACK_COLOR: '#A30200'
SLACK_TITLE: Release failed for ${{ github.repository }}
SLACK_MESSAGE: Release failed for version ${{ steps.set-tag.outputs.TAG_NAME }} of ${{ github.repository }}