-
Notifications
You must be signed in to change notification settings - Fork 1
152 lines (128 loc) · 4.08 KB
/
release-new-version.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release New Version
run-name: New release for "${{ github.ref_name }}" triggered by ${{ github.actor }}
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
workflow_call:
inputs:
version:
required: true
type: string
env:
ECR_REPOSITORY: "filplus-backend"
jobs:
format_and_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
- name: Run Clippy
run: cargo clippy
end_to_end_tests:
runs-on: ubuntu-latest
needs: format_and_lint
environment: staging-fidl
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run tests
env:
GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }}
DB_URL: ${{secrets.DB_URL}}
run: cargo test -- --nocapture
build_and_push:
runs-on: ubuntu-latest
needs: [format_and_lint, end_to_end_tests]
environment: production-fidl
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-build-
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
registry-type: public
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }}
tags: |
type=semver,pattern={{version}},value=v${{ inputs.version }}
type=ref,event=branch
type=ref,event=pr,pattern={{branch}}
# - name: Build tag and push Docker image
# uses: docker/build-push-action@v6
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
# github-token: ${{ secrets.GITHUB_TOKEN }}
# - name: Create and push tag
# if: inputs.version != ''
# run: |
# TAG_NAME="v${{ steps.meta.outputs.tags }}"
# git tag $TAG_NAME
# git push origin $TAG_NAME