Skip to content

Commit

Permalink
Add GHA for build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
dontlaugh committed Sep 11, 2024
1 parent 338f062 commit 7102d0b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and Test

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run test script
run: ./scripts/test.sh

build:
runs-on: ubuntu-latest
needs: test
env:
QUAY_USERNAME: chroot.club+cro_robot_rw
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and push container
run: ./scripts/cibuild.sh container


4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM docker.io/rakudo-star:latest

# docker build --build-arg quay_expiration="4w" -t quay.io/your-repo/your-image:tag .
ARG quay_expiration=never
LABEL quay.expires-after=${quay_expiration}

RUN apt-get update -y && \
apt-get install -y uuid-dev libpq-dev libssl-dev unzip build-essential && \
apt-get purge -y
Expand Down
34 changes: 34 additions & 0 deletions scripts/cibuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -e

cmd_container () {
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
tag_version="v1.$(date +%Y%m%d).${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"

echo $QUAY_PASSWORD | docker login quay.io -u $QUAY_USERNAME --password-stdin
full_tag="quay.io/chroot.club/cro-website:${tag_version}"
docker build \
--build-arg quay_expiration="8w" \
-t $full_tag

}


if [ -z $1 ]; then
cmd_container
fi

CMD=$1
shift
case $CMD in
container)
cmd_$CMD $@
;;
*)
echo "unknown command $CMD"
exit 1
;;
esac


4 changes: 4 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

zef test .

0 comments on commit 7102d0b

Please sign in to comment.