Skip to content

Commit

Permalink
chore: add ci/cd to build
Browse files Browse the repository at this point in the history
  • Loading branch information
leoguillaumegouv committed Jul 11, 2024
1 parent 57dc7e1 commit 76ff112
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build docker image when pushing on main branch

on:
push:
branches:
- main
- dev

jobs:
build-fastapi:
environment: ${{ github.ref_name == 'dev' || github.ref_name == 'main' }}
name: Build and push from ${{ github.ref_name }}/${{ github.sha }}
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/fastapi
IMAGE_TAG: ${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
context: app
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
#,${{ env.IMAGE_NAME }}:${{ github.ref_name == 'dev' && 'latest' || github.ref_name == 'main' && 'stable' }}
4 changes: 2 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "3.8"

services:
api:
image: albert/api:latest
fastapi:
image: ghcr.io/etalab-ia/albert-api/fastapi:latest
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
build:
context: ./app
Expand Down

0 comments on commit 76ff112

Please sign in to comment.