-
Notifications
You must be signed in to change notification settings - Fork 5
90 lines (78 loc) · 2.84 KB
/
build.yaml
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
name: Release
on:
push:
branches-ignore: [master]
pull_request:
types: [closed]
branches: [master]
workflow_dispatch:
env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
jobs:
check:
name: Check
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.get-changed-packages.outputs.packages }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Get Changed Packages
id: get-changed-packages
run: |
export PACKAGES=$(git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha || 'origin/master' }} ${{ github.sha }} ./*/ | cut -f1 -d/ | sort | uniq | jq -rcnR '[inputs]')
if ${{ github.event_name == 'workflow_dispatch' }}; then
export PACKAGES='["BlobViaEventGrid","EventHub","StorageQueue"]'
fi
echo "$PACKAGES"
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
build:
name: Build
if: needs.check.outputs.packages != '[]'
runs-on: ubuntu-latest
env:
AWS_SERVERLESS_BUCKET: ${{ secrets.AWS_PUBLIC_BUCKET }}
needs: [check]
strategy:
matrix:
package: ${{ fromJSON(needs.check.outputs.packages) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: install AWS cli
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Install functools
run: npm install -g azure-functions-core-tools@4 --unsafe-perm true
- name: Install dependencies
working-directory: ./${{ matrix.package }}
run: npm install
- name: Build
working-directory: ./${{ matrix.package }}
run: npm run build:production
- name: Package
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
working-directory: ./${{ matrix.package }}
run: zip -r ${{ matrix.package }}.zip . -x ".*"
- name: Setup AWS credentials
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CS_DEVOPS_S3_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CS_DEVOPS_S3_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Upload to S3
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
working-directory: ./${{ matrix.package }}
run: |
aws s3 cp \
${{ matrix.package }}.zip \
s3://${{ env.AWS_SERVERLESS_BUCKET }}/azure-functions-repo/${{ matrix.package }}.zip