-
Notifications
You must be signed in to change notification settings - Fork 50
129 lines (113 loc) · 5.46 KB
/
Copy pathcreate-testing-zip.yml
File metadata and controls
129 lines (113 loc) · 5.46 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
name: Build Module ZIPs - INT/PREPROD
on:
pull_request:
types: [edited, labeled, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
generate-shared-date:
name: Generate shared date for all matrix jobs
runs-on: ubuntu-latest
if: |
contains(github.event.pull_request.labels.*.name, 'preproduction deployment') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle1') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle2') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle3') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle4') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle5') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle6') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle7') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle8') ||
contains(github.event.pull_request.labels.*.name, 'prestabulle9')
outputs:
shared_date: ${{ steps.date.outputs.date }}
steps:
- name: Generate shared date
id: date
run: |
date=$(date -d '+2 hours' +'%Y-%m-%d_%H-%M-%S')
echo "date=$date" >> $GITHUB_OUTPUT
prepare-zip:
needs: [generate-shared-date]
name: Prepare module ZIP artifacts
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
strategy:
fail-fast: false
matrix:
module:
- { dir: ps17, suffix: 7, php: '7.2' }
- { dir: ps8, suffix: 8, php: '8.1' }
- { dir: ps9, suffix: 9, php: '8.4' }
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Determine Environment
id: environment
env:
LABELS_JSON: ${{ toJSON(github.event.pull_request.labels) }}
run: |
# Get all labels as a JSON array and extract names
echo "Labels JSON: $LABELS_JSON"
# Extract label names using jq
LABEL_NAMES=$(echo "$LABELS_JSON" | jq -r '.[].name' | tr '\n' ' ')
# Check for integration labels (prestabulle1 through prestabulle9)
if echo "$LABEL_NAMES" | grep -q "prestabulle[1-9]"; then
echo "environment=integration" >> $GITHUB_OUTPUT
echo "provider_secret=WI_PROVIDER_V2_INTEGRATION" >> $GITHUB_OUTPUT
echo "sa_secret=WI_SA_V2_INTEGRATION" >> $GITHUB_OUTPUT
echo "gcp_project_secret=GCP_PROJECT_INTEGRATION" >> $GITHUB_OUTPUT
# Extract the specific prestabulle number
PRESTABULLE_LABEL=$(echo "$LABEL_NAMES" | grep -o "prestabulle[1-9]" | head -1)
echo "secret_name=module-v5-$PRESTABULLE_LABEL-env" >> $GITHUB_OUTPUT
echo "prestabulle_label=$PRESTABULLE_LABEL" >> $GITHUB_OUTPUT
echo "Detected integration environment with label: $PRESTABULLE_LABEL"
elif echo "$LABEL_NAMES" | grep -q "preproduction deployment"; then
echo "environment=preproduction" >> $GITHUB_OUTPUT
echo "provider_secret=WI_PROVIDER_V2_PREPRODUCTION" >> $GITHUB_OUTPUT
echo "sa_secret=WI_SA_V2_PREPRODUCTION" >> $GITHUB_OUTPUT
echo "gcp_project_secret=GCP_PROJECT_PREPRODUCTION" >> $GITHUB_OUTPUT
echo "secret_name=module-v5-env" >> $GITHUB_OUTPUT
echo "Detected preproduction environment"
else
echo "No matching labels found. Available labels: $LABEL_NAMES"
exit 1
fi
- name: Auth GCP 🔑
uses: ./.github/actions/auth-gcp
with:
provider: ${{ secrets[steps.environment.outputs.provider_secret] }}
service-account: ${{ secrets[steps.environment.outputs.sa_secret] }}
registry-login: true
setup-gcloud: true
- name: Write .env file 🌳
run: gcloud --quiet beta secrets versions access latest --project=$GCP_PROJECT --secret="$SECRET_NAME" > .env
env:
GCP_PROJECT: ${{ secrets[steps.environment.outputs.gcp_project_secret] }}
SECRET_NAME: ${{ steps.environment.outputs.secret_name }}
- name: Package module
id: package
uses: ./.github/actions/package-module
with:
module_dir: ${{ matrix.module.dir }}
module_suffix: ${{ matrix.module.suffix }}
php_version: ${{ matrix.module.php }}
release_filename: ps_checkout.${{ matrix.module.suffix }}.zip
- name: Generate GCP bucket filename
id: bucket-filename
run: |
# Use prestabulle label for integration, environment name for preproduction
if [[ "${{ steps.environment.outputs.environment }}" == "integration" ]]; then
ENV_LABEL="${{ steps.environment.outputs.prestabulle_label }}"
else
ENV_LABEL="${{ steps.environment.outputs.environment }}"
fi
echo "filename=pr${{ github.event.pull_request.number }}/ps_checkout-${{ matrix.module.suffix }}-$ENV_LABEL-${{ github.event.pull_request.number }}-${{ needs.generate-shared-date.outputs.shared_date }}.zip" >> $GITHUB_OUTPUT
- name: Upload directly to GCP bucket storage
run: |
gsutil cp "${{ steps.package.outputs.zip_path }}" \
gs://ps-eu-w1-checkout-assets-${{ steps.environment.outputs.environment }}/${{ steps.bucket-filename.outputs.filename }}