-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (109 loc) · 2.98 KB
/
ci.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
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
name: Check, build and deploy
on: [push, pull_request]
jobs:
check-code:
name: Check code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
skip-go-installation: true
- name: Tidy
run: bash scripts/tidy.sh
- name: Test
run: bash scripts/test.sh
build-and-pack:
name: Build and pack
runs-on: ubuntu-latest
permissions:
id-token: write
env:
BINARY_NAME: almendruco
outputs:
package-name: ${{ steps.pack.outputs.package-name }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Build
run: bash scripts/build.sh ${BINARY_NAME}
- name: Pack
id: pack
run: |
PACKAGE_NAME=${BINARY_NAME}-$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD).zip
bash scripts/pack.sh ${BINARY_NAME} ${PACKAGE_NAME}
echo "::set-output name=package-name::${PACKAGE_NAME}"
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: package
path: ${{ steps.pack.outputs.package-name }}
deploy-dry-run:
name: Deploy (dry-run)
runs-on: ubuntu-latest
needs:
- build-and-pack
permissions:
id-token: write
env:
LAMBDA_NAME: almendruco
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
- name: Checkout code
uses: actions/checkout@v2
- name: Download package
uses: actions/download-artifact@v2
with:
name: package
- name: Update lambda (dry-run)
run: |
bash scripts/update.sh \
${LAMBDA_NAME} \
${{ needs.build-and-pack.outputs.package-name }} \
>/dev/null
deploy:
name: Deploy (production, main only)
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- check-code
- build-and-pack
- deploy-dry-run
permissions:
id-token: write
env:
LAMBDA_NAME: almendruco
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 900
- name: Checkout code
uses: actions/checkout@v2
- name: Download package
uses: actions/download-artifact@v2
with:
name: package
- name: Update lambda
run: |
bash scripts/update.sh -r \
${LAMBDA_NAME} \
${{ needs.build-and-pack.outputs.package-name }} \
>/dev/null