-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (78 loc) · 2.94 KB
/
release.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
name: Upload new release
on:
release:
types: [published]
jobs:
build_function:
name: Build function
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: '1.19'
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
upload_to_buckets:
name: Upload to S3 buckets
runs-on: ubuntu-latest
needs: build_function
strategy:
matrix:
aws_region:
- 'us-east-1'
- 'us-east-2'
- 'us-west-1'
- 'us-west-2'
- 'eu-central-1'
- 'eu-north-1'
- 'eu-west-1'
- 'eu-west-2'
- 'eu-west-3'
- 'sa-east-1'
- 'ap-northeast-1'
- 'ap-northeast-2'
- 'ap-northeast-3'
- 'ap-south-1'
- 'ap-southeast-1'
- 'ap-southeast-2'
- 'ca-central-1'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download release for security hub collector
run: wget -c https://github.com/logzio/aws-security-hub/releases/download/${{ github.event.release.tag_name }}/aws-security-hub_${{ github.event.release.tag_name }}_linux_amd64.zip -O function.zip
- name: create new version
run: |
cp ./collector/sam/template.yaml ./template-${{ matrix.aws_region }}.yaml
sed -i "s/<<VERSION>>/${{ github.event.release.tag_name }}/" "./template-${{ matrix.aws_region }}.yaml"
sed -i "s/<<REGION>>/${{ matrix.aws_region }}/" "./template-${{ matrix.aws_region }}.yaml"
shell: bash
- name: Upload to aws
run: |
sudo apt-get update
sudo apt-get install awscli
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_KEY }}
aws configure set region ${{ matrix.aws_region }}
aws s3 cp ./template-${{ matrix.aws_region }}.yaml s3://logzio-aws-integrations-${{ matrix.aws_region }}/aws-security-hub-collector/${{ github.event.release.tag_name }}/template.yaml --acl public-read
aws s3 cp ./function.zip s3://logzio-aws-integrations-${{ matrix.aws_region }}/aws-security-hub-collector/${{ github.event.release.tag_name }}/function.zip --acl public-read
shell: bash
- name: Clean
run: |
rm ./template-${{ matrix.aws_region }}.yaml
rm ./function.zip