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 e0de01a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Publish Image
on:
push: {}
repository_dispatch:
types: [fe-change, be-change]

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

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

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

# this the last so we end up inside the cloned directory
- uses: actions/checkout@v4
with:
path: expenses-container

- uses: actions/setup-node@v4
with:
node-version: 16

- name: Build code
id: build-code
env:
DISABLE_ESLINT_PLUGIN: "true"
run: |
cd expenses-container \
&& bash -x ./build.sh --skip-image-build ../expenses-react ../expenses_server_fastapi
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"

# for arm image building
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: expenses
context: expenses-container
platforms: linux/arm64/v8
tags: latest ${{ github.sha }} ${{ steps.date.outputs.date }}
containerfiles: |
./expenses-container/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 e0de01a

Please sign in to comment.