-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (145 loc) · 5.74 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
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: 8.3
- name: Install dependencies
run: composer install
- name: Audit
run: composer audit
- name: Code Style
run: |
curl -L https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.57.2/php-cs-fixer.phar -o php-cs-fixer
chmod a+x php-cs-fixer
./php-cs-fixer fix --config=.php-cs-fixer.dist.php --cache-file=.php-cs.cache --diff --dry-run --verbose
build-zip-default:
name: Build the ZIP
needs: [check]
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.4
- name: Build ZIP
run: ./release/build_release_package.sh
env:
TAG_NAME: ${{ steps.set-tag.outputs.TAG_NAME }}
- name: Rename ZIP file
run: mv ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}.zip ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-default.zip
- name: Store to cache
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-default.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-default
build-zip-guzzle-7-4:
name: Build the ZIP with Guzzle 7.4 pinned
needs: [check]
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.4
- name: Require Guzzle ~7.4.5
run: composer require "guzzlehttp/guzzle:~7.4.5"
- name: Build ZIP
run: ./release/build_release_package.sh
env:
TAG_NAME: ${{ steps.set-tag.outputs.TAG_NAME }}
- name: Rename ZIP file
run: mv ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}.zip ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-guzzle-7.4.zip
- name: Store to cache
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-guzzle-7.4.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-guzzle-7.4
release:
name: Create GitHub release & attach ZIP files
needs: [build-zip-default, build-zip-guzzle-7-4]
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 (regular ZIP)
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-default.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-default
- name: Load from cache (Guzzle 7.4 ZIP)
uses: actions/cache@v4
with:
path: ./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-guzzle-7.4.zip
key: ${{ steps.set-tag.outputs.TAG_NAME }}-${{ github.sha }}-guzzle-7.4
- name: Release & upload
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.set-tag.outputs.TAG_NAME }}
name: Shopgate Ship from Store for Shopware 5 ${{ steps.set-tag.outputs.TAG_NAME }}
draft: true
prerelease: true
fail_on_unmatched_files: true
files: |
./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-default.zip
./release/shopgate-shopware5-sfs-${{ steps.set-tag.outputs.TAG_NAME }}-guzzle-7.4.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 }}