-
Notifications
You must be signed in to change notification settings - Fork 9
73 lines (71 loc) · 2.68 KB
/
build-aws.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
on:
workflow_call:
secrets:
AWS_ACCESS_KEY_ID:
description: AWS Access Key
required: true
AWS_SECRET_ACCESS_KEY:
description: AWS Secret Key
required: true
AWS_ACCOUNT_ID:
description: AWS Account ID
required: true
REPOSITORY_NAME:
description: ECR Repository Name
required: true
inputs:
project-name:
description: Name of the CodeBuild Project
required: false
default: OpenMPDK_DSS
type: string
compute-type-override:
description: Compute type for CodeBuild runtime
required: false
default: BUILD_GENERAL1_SMALL
type: string
component:
description: Name of the component you want to build (for display only)
required: true
type: string
buildspec:
description: CodeBuild buildspec filename (inside ./buildspec/) - Derived from 'component' by default
required: false
type: string
image:
description: Custom image to use for CodeBuild runtime, if not the default dss-build image
required: false
type: string
jobs:
build-aws:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
- name: Derive the branchname for ECR tag (replace '/' with '_')
id: nice_branchname
run: |
# Use base_ref if PR
if [[ "${{ github.ref_name }}" == *"/merge" ]]
then
BRANCH_NAME="${{ github.base_ref }}"
# Use ref_name if merge
else
BRANCH_NAME="${{ github.ref_name }}"
fi
echo "NICE_BRANCHNAME=$(echo "$BRANCH_NAME" | tr '/' '_')" >> "$GITHUB_OUTPUT"
shell: bash
- name: "Execute ${{ inputs.component }} workflow on CodeBuild"
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ inputs.project-name }}
compute-type-override: ${{ inputs.compute-type-override }}
buildspec-override: "./buildspec/${{ inputs.buildspec != '' && inputs.buildspec || format('{0}.yml', inputs.component) }}"
image-override: "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-west-1.amazonaws.com/${{ secrets.REPOSITORY_NAME }}:${{ inputs.image != '' && inputs.image || format('dss-build_{0}', steps.nice_branchname.outputs.NICE_BRANCHNAME) }}"
env-vars-for-codebuild: SONAR_SCANNER_URL
env:
SONAR_SCANNER_URL: ${{ vars.SONAR_SCANNER_URL }}