-
Notifications
You must be signed in to change notification settings - Fork 19
142 lines (118 loc) · 3.96 KB
/
build-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
140
141
142
name: Build & Release
on:
pull_request:
types: [opened, reopened]
release:
types: [released, prereleased]
push:
branches-ignore:
- feat/*
- fix/*
env:
LABELS: ${{toJSON(github.event.pull_request.labels)}}
jobs:
deploy:
name: build dependencies & create artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: 'actions/checkout@v4'
with:
path: ''
- name: Install composer dependencies
run: composer install --no-dev -o
- name: Clean-up project
uses: 'PrestaShopCorp/[email protected]'
- name: Cache module folder
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
upload_asset_preproduction:
runs-on: ubuntu-latest
needs: [deploy]
permissions:
contents: 'read'
id-token: 'write'
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- name: Retrieve from cache module folder
id: retrieve-cache
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
- name: Check if retrieved from cache was successful
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: exit 1
- name: Auth GCP
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WI_PROVIDER_PREPRODUCTION }}
service_account: ${{ secrets.WI_SA_PREPRODUCTION }}
project_id: ${{ env.GCP_PROJECT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ env.GCP_PROJECT }}
- name: Copy env files
run: |
gcloud secrets versions access latest --project $GCP_PROJECT --secret=mbo-module-env > .env
rm -f .env.dist
- name: Remove test settings files
run: |
rm -f gha-*.json
- name: Prepare the zip
run: |
cd ..
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Create & upload artifact for preprod
uses: 'actions/upload-artifact@v4'
with:
name: ${{ github.event.repository.name }}.preprod
path: /home/runner/work/ps_mbo/${{ github.event.repository.name }}.zip
upload_release_asset_production:
name: Upload the production zip asset to the release
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
if: github.event_name == 'release'
needs: deploy
steps:
- name: Retrieve from cache module folder
id: retrieve-cache
uses: 'actions/cache@v4'
with:
path: ./
key: ${{ github.run_id }}
- name: Check if retrieved from cache was successful
if: steps.retrieve-cache.outputs.cache-hit != 'true'
run: exit 1
- name: Auth GCP
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WI_PROVIDER_PRODUCTION }}
service_account: ${{ secrets.WI_SA_PRODUCTION }}
project_id: ${{ env.GCP_PROJECT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ env.GCP_PROJECT }}
- name: Copy env files
run: |
rm -f .env.dist
gcloud secrets versions access latest --project $GCP_PROJECT --secret=mbo-module-env > .env
- name: Remove test settings files
run: |
rm -f gha-*.json
rm -f ./src/Traits/HaveConfigurationPage.php
sed -i '/HaveConfigurationPage/d' ps_mbo.php
- name: Prepare the production zip
run: |
cd ..
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Publish the production zip
uses: softprops/action-gh-release@v1
with:
files: ../${{ github.event.repository.name }}.zip