-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (118 loc) · 4.24 KB
/
live-release.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
name: 🚀 Create Release
on:
# This action is triggered manually.
workflow_dispatch:
inputs:
version:
description: 'The version number of this release. Runs `npm version`.'
required: true
default: 'patch'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_TOKEN }}
- uses: actions/setup-node@v1
with:
node-version: 16
- name: ⚙️ Configure git
run: |
git config user.name $GITHUB_ACTOR
git config user.email gh-actions-${GITHUB_ACTOR}@github.com
- name: ⚙️ Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer:v2
- name: 💾 Get node.js cache directory
id: node-cache-dir
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT # Use $(yarn cache dir) for yarn
- name: 💾 Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.node-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node-
- name: 💾 Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: ⚙️ Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: ⚙️ Install Composer Packages
run: composer install --optimize-autoloader
env:
APP_ENV: dev
- name: ⚙️ Install Node Packages
run: npm ci
- name: ⚙️ Build the assets
run: npm run build
- name: ✍️ Create Changelog
shell: bash
id: changelog
run: |
log=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:'* %s (%h)')
log="${log//'%'/'%25'}"
log="${log//$'\n'/'%0A'}"
log="${log//$'\r'/'%0D'}"
echo "log=$log" >> $GITHUB_OUTPUT
- name: Check Status
run: git status
- name: 🔼 Bump version
run: npm version ${{ github.event.inputs.version }} -m 'Tagging %s'
- name: ⚙️ Get new version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Push the version to git
run: |
git push
env:
GITHUB_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
- name: 🚀 Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
body: |
${{ steps.changelog.outputs.log }}
tag_name: v${{ steps.version.outputs.version }}
- name: 🚢 Deploy to Live Server
if: ${{ success() }}
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.liveservFtpHost }}
username: ${{ secrets.liveservFtpUser }}
password: ${{ secrets.liveservFtpPassword }}
local-dir: ./
server-dir: ./symfony/
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
var/**
.vscode/**
vendor/**
- name: 🖥 Perform migrations
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.liveservFtpHost }}
username: ${{ secrets.LIVESERVSSHUSER }}
password: ${{ secrets.LIVESERVSSHPASS }}
port: 22
script: |
source ~/.zshrc
cd symfony
symfony console messenger:stop-workers
composer install -n --optimize-autoloader
symfony console doctrine:cache:clear-metadata -n
symfony console doctrine:migrations:diff --allow-empty-diff -n
symfony console doctrine:migrations:migrate -n --allow-no-migration
symfony console cache:clear -n