forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy path4_builderpackage_dashboard_core.yml
More file actions
131 lines (110 loc) · 4.92 KB
/
Copy path4_builderpackage_dashboard_core.yml
File metadata and controls
131 lines (110 loc) · 4.92 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
# This is a basic workflow that is manually triggered
#
# This workflow automates the build of Wazuh dashboard core for different
# architectures and distributions.
#
# This workflow:
# - Clone, configure, build and package the Wazuh dashboard core.
# - Customizable in architecture and reference (`branch/tag/commit`).
# - Upload the final package with a structured name.
name: (4.x) Build Wazuh dashboard core package (on demand)
on:
workflow_call:
inputs:
CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'main'
description: 'The branch/tag/commit to checkout to'
required: true
default: 'main'
type: string
ARCHITECTURE:
description: 'The architecture to build the package for'
required: true
default: 'amd64'
type: string
execution_repository:
description: 'Repository and workflow run to upload the artifact to (format: repo/workflow). This is used to locate the artifacts in S3.'
required: true
default: ''
type: string
workflow_dispatch:
inputs:
CHECKOUT_TO: # This is the branch to checkout to. Defaults to 'main'
description: 'The branch/tag/commit to checkout to'
required: true
default: 'main'
ARCHITECTURE:
description: 'The architecture to build the package for'
required: true
default: 'amd64'
type: string
env:
CI_DEV_INTERNAL_BUCKET: ${{ secrets.CI_DEV_INTERNAL_BUCKET }}
# Repository and workflow run to upload the artifact to (format: repo/workflow). This is used to locate the artifacts in S3.
EXECUTION_REPOSITORY: wazuh-dashboard/4_builderpackage_dashboard_core
jobs:
build:
runs-on: ${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && format('codebuild-github-actions-codebuild-runner-dashboard-amd-{0}-{1}', github.run_id, github.run_attempt) || format('codebuild-github-actions-codebuild-runner-dashboard-arm-{0}-{1}', github.run_id, github.run_attempt) }}
name: Build
defaults:
run:
working-directory: ./artifacts
strategy:
matrix:
DISTRIBUTION: [tar.gz]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: wazuh/wazuh-dashboard
path: ./artifacts
ref: ${{ inputs.CHECKOUT_TO }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: './artifacts/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Setup Yarn
run: |
npm uninstall -g yarn
npm i -g yarn@1.22.10
yarn config set network-timeout 1000000 -g
- name: Configure Yarn Cache
run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV
- name: Initialize Yarn Cache
uses: actions/cache@v4
with:
path: ${{ env.YARN_CACHE_LOCATION }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
- name: Get package version
run: |
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
echo "WZD_VERSION=$(yarn --silent wzd-version)" >> $GITHUB_ENV
echo "WZD_REVISION=$(yarn --silent wzd-revision)" >> $GITHUB_ENV
- name: Get artifact build name
run: |
echo "ARTIFACT_BUILD_NAME=wazuh-dashboard_${{ env.WZD_VERSION }}-${{ env.WZD_REVISION }}_${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'x64' || 'arm64' }}.${{ matrix.DISTRIBUTION }}" >> $GITHUB_ENV
- name: Create non-root build user
run: |
useradd -m builduser
chown -R builduser:builduser .
- name: Run bootstrap
run: |
chown -R builduser:builduser "$YARN_CACHE_LOCATION" 2>/dev/null || true
sudo -u builduser -H env PATH="$PATH" yarn osd bootstrap
- name: Build
run: sudo -u builduser -H env PATH="$PATH" yarn build-platform --${{(inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'linux' || 'linux-arm'}} --skip-os-packages --release
- name: Rename artifact
run: mv target/opensearch-dashboards-${{ env.VERSION }}-linux-${{ (inputs.ARCHITECTURE == 'x86_64' || inputs.ARCHITECTURE == 'amd64') && 'x64' || 'arm64' }}.${{ matrix.DISTRIBUTION }} target/${{ env.ARTIFACT_BUILD_NAME }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload artifact to S3
run: |
artifact_path=${{ github.workspace }}/artifacts/target/${{ env.ARTIFACT_BUILD_NAME }}
bucket_path="${{ env.CI_DEV_INTERNAL_BUCKET }}/${{ inputs.execution_repository || env.EXECUTION_REPOSITORY }}/${{ github.run_id }}/${{ env.ARTIFACT_BUILD_NAME }}"
aws s3 cp $artifact_path $bucket_path
echo "Artifact uploaded to S3: $bucket_path"