-
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (143 loc) · 6.44 KB
/
build.yml
File metadata and controls
152 lines (143 loc) · 6.44 KB
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
name: Build and deploy
on:
push:
release:
types: [published]
jobs:
buildBackend:
name: Build backend
runs-on: ubuntu-latest
environment: deploy_on_release
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 100
- name: "install PHP and composer"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "intl, zip, xml, apcu"
ini-values: "memory_limit=-1"
php-version: "8.4"
tools: "composer"
- name: "Export Git repo"
run: |
# Remove a possibly existing extraction folder
rm -rf extract
# No that we are sure it's not there, create an empty extraction folder
mkdir extract
# Create an archive from the repository based on the given tag
# and extract that into the just created extraction folder.
git archive --prefix="./" --format=tar ${{ github.head_ref || github.ref_name }} .| tar xv -C extract/
# Do some shell magic to replace occurrences of the string '%release-tag%'
# with the current release tag in all files within the extraction folder
find extract/ -type f -exec sed -i "s/%release-tag%/:${{ github.head_ref || github.ref_name }}/" {} \;
# Move into the extraction folder
cd extract
# Call composer install to add all your dependencies, prefer the
# distribution ones and create an authoritative and optimized autoloader
composer install --no-dev --prefer-dist -a
# Go back one level
rm -rf frontend compose*
cd ..
# Create the actual archive that you want to deploy
tar cvzf backend-${{ github.head_ref || github.ref_name }}.tgz -C extract/ .
# clean up the extraction folder
rm -rf extract
- uses: actions/upload-artifact@v4
with:
name: backend
path: backend-${{ github.head_ref || github.ref_name }}.tgz
retention-days: 1
buildFrontend:
name: "Build Frontend"
runs-on: ubuntu-latest
environment: deploy_on_release
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 100
- name: "install Node"
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: "Export Git repo"
run: |
# Remove a possibly existing extraction folder
rm -rf extract
# No that we are sure it's not there, create an empty extraction folder
mkdir extract
# Create an archive from the repository based on the given tag
# and extract that into the just created extraction folder.
git archive --prefix="./" --format=tar ${{ github.head_ref || github.ref_name }} .| tar xv -C extract/
# Do some shell magic to replace occurrences of the string '%release-tag%'
# with the current release tag in all files within the extraction folder
find extract/ -type f -exec sed -i "s/%release-tag%/:${{ github.head_ref || github.ref_name }}/" {} \;
# Move into the extraction folder
cd extract/frontend
# Call Node.js install to add all your dependencies, prefer the
npm ci
npm run build
# Go back one level
cd ..
rm -rf config src templates vendor frontend compose*
cd ..
# Create the actual archive that you want to deploy
tar cvzf frontend-${{ github.head_ref || github.ref_name }}.tgz -C extract/ .
# clean up the extraction folder
rm -rf extract
- uses: actions/upload-artifact@v4
with:
name: frontend
path: frontend-${{ github.head_ref || github.ref_name }}.tgz
retention-days: 1
buildFrontendContainer:
needs: buildFrontend
name: "Build Frontend-COntainer"
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- uses: actions/download-artifact@v4
with:
name: frontend
- name: 'Build Inventory Image'
run: |
mkdir -p .docker/nginx/build
tar xvzf frontend-${{ github.head_ref || github.ref_name }}.tgz -C .docker/nginx/build
cp .env.dist .env
docker compose build nginx
docker compose push nginx
buildBackendContainer:
needs: buildBackend
name: "Build Backend-COntainer"
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- uses: actions/download-artifact@v4
with:
name: backend
- name: 'Build Inventory Image'
run: |
mkdir -p .docker/php/build
tar xvzf backend-${{ github.head_ref || github.ref_name }}.tgz -C .docker/php/build
cp .env.dist .env
docker compose build php
docker compose push php