-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (74 loc) · 2.21 KB
/
cicd.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
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Cache toolchains and crates
uses: actions/cache@v3
with:
path: |
~/.rustup/settings.toml
~/.rustup/toolchains
~/.rustup/update-hashes
~/.cargo/registry
~/.cargo/git
key: toolchains-and-crates-${{ runner.os }}
- uses: actions/checkout@v4
- name: Cache build results
uses: actions/cache@v3
with:
path: target
key: build-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- run: rustup target add x86_64-unknown-linux-musl
- run: sudo apt-get install musl-tools
- run: cargo fmt --all -- --check
continue-on-error: true
- run: cargo build --release
- run: |
cp target/x86_64-unknown-linux-musl/release/sns-discord bootstrap
zip -j lambda.zip bootstrap && rm bootstrap
- run: cargo test
- run: cargo clippy -- -D warnings
- uses: actions/upload-artifact@v3
with:
name: build
path: lambda.zip
fmt-prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: creyD/prettier_action@v4.3
with:
dry: true
prettier_options: --check **/*.{md,yaml,yml}
deploy:
if: |
github.repository_owner == 'femiwiki' &&
github.ref == 'refs/heads/main' &&
github.event_name == 'push'
needs:
- test
runs-on: ubuntu-latest
strategy:
matrix:
region:
- us-east-1
- ap-northeast-1
steps:
- uses: actions/download-artifact@v3
with:
name: build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ matrix.region }}
- run: |
aws lambda update-function-code \
--function-name DiscordNoti \
--zip-file fileb://lambda.zip \
--region "${{ matrix.region }}" \
--publish