forked from aws-solutions/serverless-image-handler
-
Notifications
You must be signed in to change notification settings - Fork 2
114 lines (103 loc) · 3.25 KB
/
deploy.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
name: main
on:
push:
branches:
- main
paths-ignore:
- "**.tf"
pull_request:
branches:
- main
paths-ignore:
- "**.tf"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# read+write needed for `aws-actions/configure-aws-credentials` to work
permissions:
id-token: write
contents: read
jobs:
image-handler:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: install
run: make FUNC=image-handler npm/install
- name: install
run: make FUNC=image-handler npm/test
- name: build
run: make FUNC=image-handler build
- name: configure aws credentials
# 📌 Runs only if:
# 1. is a 'push to main'
# 2. did not run in a fork
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'stroeer' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::053041861227:role/github-s3-access-eu-west-1
role-session-name: GitHubActions
aws-region: eu-west-1
- name: s3 upload artefact
# 📌 Runs only if:
# 1. is a 'push to main'
# 2. did not run in a fork
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'stroeer' }}
run: make FUNC=image-handler deploy
thumbnail-generator:
env:
CARGO_TERM_COLOR: always
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: install cargo lambda
run: pip3 install cargo-lambda
- name: cargo lambda build
run: make build FUNC=thumbs
- name: configure aws credentials
# 📌 Runs only if:
# 1. is a 'push to main'
# 2. did not run in a fork
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'stroeer' }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::053041861227:role/github-s3-access-eu-west-1
role-session-name: GitHubActions
aws-region: eu-west-1
- name: s3 upload artefact
# 📌 Runs only if:
# 1. is a 'push to main'
# 2. did not run in a fork
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'stroeer' }}
run: make deploy FUNC=thumbs