Skip to content

Commit

Permalink
Added github workflow
Browse files Browse the repository at this point in the history
This includes adding the '--skip-image-build' option to the build
script.

Signed-off-by: David Caro <[email protected]>
  • Loading branch information
david-caro committed May 2, 2024
1 parent a95989b commit cff158b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Publish Image
on: [push]

jobs:
build:
name: Build and publish image
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: farting-lizards/expenses_server_fastapi

- uses: actions/checkout@v4
with:
repository: farting-lizards/expenses-react

- name: Build code
id: build-code
run: |
./build.sh --skip-image-build expenses_server_fastapi expenses_react
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: expenses
tags: latest ${{ github.sha }} ${{ steps.date.outputs.date }}
containerfiles: |
./Dockerfile.prod
- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/farting_lizards
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Print image url
run: |
echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
12 changes: 11 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function help() {
If specified, will only build the container, but not copy
any code or files from the frontend or the backend
--skip-image-build
If specified, it will not build the container image (usually for CI)
Arguments:
PATH_TO_FRONTEND_REPO
Path to the directory containing the frontend code.
Expand All @@ -37,6 +40,7 @@ EOH

function main() {
local do_build=true
local do_image_build=true
if [[ $# -lt 3 ]]; then
echo "Not enough arguments passed"
help
Expand All @@ -54,6 +58,10 @@ function main() {
do_build=false
shift
fi
if [[ "$1" == "--skip-image-build" ]]; then
do_image_build=false
shift
fi
local fe_path="${1:?No frontend path passed}"
local be_path="${2:?No backend path passed}"
local env="${3:-}"
Expand All @@ -75,7 +83,9 @@ function main() {
copyFrontend "$fe_path" "src/static"
fi

buildContainer "$arch" "$dockerfile"
if $do_image_build; then
buildContainer "$arch" "$dockerfile"
fi

}

Expand Down

0 comments on commit cff158b

Please sign in to comment.