-
Notifications
You must be signed in to change notification settings - Fork 224
187 lines (164 loc) · 5.67 KB
/
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
---
name: Deploy
on:
push:
branches:
- 'develop'
paths:
- "bin/**"
- "config.yaml"
- "composer.json"
- "composer.lock"
- "res/**"
- "scoper.inc.php"
- "src/**"
- "version.txt"
tags:
# only tags with semver format
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
jobs:
create-signed-phar-file:
runs-on: ubuntu-latest
steps:
- name: Checkout HEAD
uses: actions/[email protected]
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
tools: composer:2
php-version: '7.4'
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Create phar
run: bash ./build.sh
- name: Run phar file
run: php n98-magerun2.phar --version
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
trust_level: 5
- name: GPG sign phar file (detached)
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | \
gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --detach-sign -a \
-o n98-magerun2.phar.asc n98-magerun2.phar
env:
GPG_TTY: $(tty)
- name: GPG verify phar file
run: gpg --verify n98-magerun2.phar.asc n98-magerun2.phar
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: n98-magerun2.phar
path: |
n98-magerun2.phar
n98-magerun2.phar.asc
update-files-magerun-net:
runs-on: ubuntu-latest
needs: ["create-signed-phar-file"]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: n98-magerun2.phar
path: .
- name: rename phar file (develop / unstable)
if: github.ref == 'refs/heads/develop'
run: |
mv n98-magerun2.phar n98-magerun2-dev.phar
mv n98-magerun2.phar.asc n98-magerun2-dev.phar.asc
ls -l
- name: rename phar file (tag)
if: startsWith(github.ref, 'refs/tags/')
run: |
# Get tag part of github.ref
TAG=$(cut -d'/' -f3 <<< "$GITHUB_REF")
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/netz98/n98-magerun2/master/version.txt | tr -d '[:space:]')
# Check if curl was successful
if [[ -z "$LATEST_VERSION" ]]; then
echo "Failed to fetch the latest version."
exit 1
fi
# Rename files
cp "n98-magerun2.phar" "n98-magerun2-${TAG}.phar"
cp "n98-magerun2.phar.asc" "n98-magerun2-${TAG}.phar.asc"
mv "n98-magerun2.phar" "n98-magerun2-latest.phar"
mv "n98-magerun2.phar.asc" "n98-magerun2-latest.phar.asc"
# List files to verify
ls -l
- name: Upload phar file to files.magerun.net
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_DEPLOY_HOST }}
username: ${{ secrets.SSH_DEPLOY_USERNAME }}
key: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_DEPLOY_PASSPHRASE }}
source: '*.phar,*.phar.asc'
target: ${{ secrets.SSH_DEPLOY_TARGET }}
rm: false
overwrite: true
- name: Run update tasks on files.magerun.net
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_DEPLOY_HOST }}
username: ${{ secrets.SSH_DEPLOY_USERNAME }}
key: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_DEPLOY_PASSPHRASE }}
script: |
build/build_phive.sh
curl -s https://files.magerun.net/list.php > public/index.html
- name: Invalidate cloudflare
run: |
curl -X POST 'https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache' \
-H 'Content-Type:application/json' \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_TOKEN }}" \
--data-raw '{"purge_everything":true}'
update-dist-repo:
runs-on: ubuntu-latest
needs: [ "create-signed-phar-file" ]
steps:
- name: Checkout HEAD
uses: actions/[email protected]
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DIST_REPO_DEPLOY_KEY }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: n98-magerun2.phar
- name: Update dist repo
env:
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
run: bash .github/workflows/update-dist-repo.sh
create-github-release:
runs-on: ubuntu-latest
needs: [ "create-signed-phar-file" ]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout HEAD
uses: actions/[email protected]
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: n98-magerun2.phar
- name: 'Build Changelog'
uses: mikepenz/release-changelog-builder-action@v5
with:
owner: "netz98"
repo: "n98-magerun2"
id: build_changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo "${{ steps.build_changelog.outputs.changelog }}"
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{steps.build_changelog.outputs.changelog}}
files: |
n98-magerun2.phar
n98-magerun2.phar.asc