Skip to content

Commit e1da357

Browse files
committed
[Web] FastAPI
V1.0.0 change list: 1.Added global job variable maps handler to CI pipeline YAML. 2.Modified status and version badges style. 3.Published to release the first version. Test Done: OK Bug: None Signed-off-by: AllennLiu <seven6306@icloud.com>
1 parent 0937c29 commit e1da357

3 files changed

Lines changed: 69 additions & 31 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,46 @@ jobs:
6868
build:
6969
runs-on: self-hosted
7070
needs: varmaps
71+
permissions:
72+
contents: read
73+
packages: write
7174
container:
72-
image: ghcr.io/allennliu/docker:18
75+
image: ghcr.io/allennliu/docker:19
7376
credentials:
7477
username: ${{ github.actor }}
7578
password: ${{ secrets.ACCESS_TOKEN }}
7679
steps:
77-
- name: Build Image
78-
run: |
79-
docker build --no-cache -t ghcr.io/${{ needs.varmaps.outputs.REPO_AUTHOR }}:${{ needs.varmaps.outputs.VERSION }} .
80-
docker images | grep -i $GITHUB_REPOSITORY || true
81-
- name: Publish to Registry
82-
run: |
83-
echo $ACCESS_TOKEN | docker login ghcr.io -u $GITHUB_REPOSITORY_OWNER --password-stdin
84-
docker push ghcr.io/${{ needs.varmaps.outputs.REPO_AUTHOR }}:${{ needs.varmaps.outputs.VERSION }}
80+
- uses: actions/checkout@v2
81+
- name: Log in to the Container registry
82+
if: github.event_name != 'pull_request'
83+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.actor }}
87+
password: ${{ secrets.ACCESS_TOKEN }}
88+
- name: Extract metadata (tags, labels) for Docker
89+
id: meta
90+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
91+
with:
92+
images: ${{ needs.varmaps.outputs.REGISTRY_IMAGE }}
93+
- name: Build and push Docker image
94+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
95+
with:
96+
context: .
97+
push: true
98+
tags: ${{ needs.varmaps.outputs.REGISTRY_IMAGE }}:${{ needs.varmaps.outputs.VERSION }}
99+
labels: ${{ steps.meta.outputs.labels }}
100+
- name: Update Package Badge
101+
uses: schneegans/dynamic-badges-action@v1.0.0
102+
with:
103+
auth: ${{ secrets.GIST_SECRET }}
104+
gistID: ab6dc65e1bc6049b57a18f32124f2ce7
105+
filename: ${{ needs.varmaps.outputs.PROJECT_NAME }}-package.json
106+
label: Package
107+
message: v${{ needs.varmaps.outputs.VERSION }}
108+
color: lightgrey
109+
namedLogo: Docker
110+
logoColor: blue
85111

86112
staging:
87113
runs-on: self-hosted
@@ -172,7 +198,7 @@ jobs:
172198
with:
173199
name: pytest-results
174200
path: report.xml
175-
- name: Create Test Coverage Badge
201+
- name: Update Test Coverage Badge
176202
if: ${{ env.COVERAGE != '' }}
177203
uses: schneegans/dynamic-badges-action@v1.0.0
178204
with:
@@ -206,16 +232,17 @@ jobs:
206232
body: ${{ github.event.head_commit.message }}
207233
draft: false
208234
prerelease: false
209-
- name: Create Release Badge
235+
- name: Update Release Badge
210236
uses: schneegans/dynamic-badges-action@v1.0.0
211237
with:
212238
auth: ${{ secrets.GIST_SECRET }}
213239
gistID: 0bf7d0bf3675b35eaa46fffc60b4ade0
214240
filename: ${{ needs.varmaps.outputs.PROJECT_NAME }}-release.json
215241
label: Release
216242
message: v${{ needs.varmaps.outputs.VERSION }}
217-
color: blue
243+
color: informational
218244
namedLogo: fastapi
245+
logoColor: success
219246

220247
clean:
221248
runs-on: self-hosted

README.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ Web-FastAPI
22
==================
33

44
## Version
5-
`Rev: 0.0.2`
5+
`Rev: 1.0.0`
66

7-
[![Release Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/0bf7d0bf3675b35eaa46fffc60b4ade0/raw/Web-FastAPI-release.json)](https://github.com/AllennLiu/Web-FastAPI/releases)
7+
[![Release Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/0bf7d0bf3675b35eaa46fffc60b4ade0/raw/Web-FastAPI-release.json)](https://github.com/AllennLiu/Web-FastAPI/releases) [![Package Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/ab6dc65e1bc6049b57a18f32124f2ce7/raw/Web-FastAPI-package.json)](https://github.com/AllennLiu/Web-FastAPI/pkgs/container/web-fastapi)
88

99
---
1010

11-
## Python Version
12-
![Python Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/ff710dd6f378c7d82792f9429f65ab31/raw/Python%2520Version)
11+
## Requirement Version
12+
![Python Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/ff710dd6f378c7d82792f9429f65ab31/raw/Python%2520Version&logoColor=violet) ![Kubernetes Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/afa8c412f07d7457a79fc0697b816c67/raw/3c75f9fbb513a8ded6d37a83d600422667a6644f/Kubernetes%2520Badge)
1313

1414
---
1515

1616
## Status
1717

18-
[![Pipeline Status](https://github.com/AllennLiu/Web-FastAPI/actions/workflows/docker-image.yml/badge.svg)](https://github.com/AllennLiu/Web-FastAPI/actions/workflows/docker-image.yml) ![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/cdc11bececff228f66cebd39b8b588dc/raw/Web-FastAPI__heads_main.json)
18+
[![Pipeline Status](https://github.com/AllennLiu/Web-FastAPI/actions/workflows/docker-image.yml/badge.svg)](https://github.com/AllennLiu/Web-FastAPI/actions/workflows/docker-image.yml) ![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/AllennLiu/cdc11bececff228f66cebd39b8b588dc/raw/Web-FastAPI__heads_main.json&logoColor=9cf)
1919

2020
---
2121

@@ -55,20 +55,23 @@ Using **`FastAPI` web framework** with _Python_ to build API services, this is *
5555

5656
## Usage
5757

58-
- More API usage please refer to following url:
59-
60-
- **FastAPI Docs - [http://web-fastapi.cloudnative.ies.inventec/docs](http://web-fastapi.cloudnative.ies.inventec/docs)**
61-
62-
- **FastAPI Redoc - [http://web-fastapi.cloudnative.ies.inventec/redoc](http://web-fastapi.cloudnative.ies.inventec/redoc)**
58+
- **服務部署在英業達公司內網,外部網路無法直接訪問,有需要可以通過 `VPN` 連線。**
6359

64-
- **Production:**
60+
- **Production 環境**
6561

6662
- **FastAPI Home - [http://web-fastapi.cloudnative.ies.inventec](http://web-fastapi.cloudnative.ies.inventec)**
6763

68-
- **Staging:**
64+
- **Staging 環境**
6965

7066
- **FastAPI Home - [http://10.99.104.251:8787/login](http://10.99.104.251:8787/login)**
7167

68+
- More API usage please refer to following url:
69+
70+
- **FastAPI Docs - [http://web-fastapi.cloudnative.ies.inventec/docs](http://web-fastapi.cloudnative.ies.inventec/docs)**
71+
72+
- **FastAPI Redoc - [http://web-fastapi.cloudnative.ies.inventec/redoc](http://web-fastapi.cloudnative.ies.inventec/redoc)**
73+
74+
7275
---
7376

7477
## Reports
@@ -146,7 +149,7 @@ Using **`FastAPI` web framework** with _Python_ to build API services, this is *
146149
## Associates
147150
148151
- **Tester**
149-
- Liu.Allen
152+
- Liu.AllenJH
150153
151154
- **Developer**
152155
- Liu.AllenJH
@@ -166,12 +169,6 @@ Using **`FastAPI` web framework** with _Python_ to build API services, this is *
166169
167170
---
168171
169-
## Coverage
170-
171-
No operation system platform coverage.
172-
173-
---
174-
175172
## Reference
176173
177174
- FastAPI - [https://fastapi.tiangolo.com](https://fastapi.tiangolo.com)

passing-image.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@
99
debug:
1010
msg: "{{ ansible_fqdn }}"
1111

12+
- name: Docker login and pull image from Github registry
13+
shell: |
14+
echo {{ access_token }} | docker login -u {{ access_user }} {{ registry_image }} --password-stdin
15+
docker pull {{ registry_image }}:{{ version }}
16+
args:
17+
executable: /bin/bash
18+
register: shell_result
19+
20+
- name: Print Result
21+
debug:
22+
msg: "{{ shell_result.stdout }}"
23+
24+
1225
- name: Archive docker image
1326
shell: |
27+
echo {{ access_token }} | docker login -u {{ access_user }} {{ registry_image }} --password-stdin
1428
docker save -o /tmp/{{ container_name }}.tar {{ registry_image }}:{{ version }}
1529
du -shx /tmp/{{ container_name }}.tar
1630
args:

0 commit comments

Comments
 (0)