diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3c2748a --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 + + diff --git a/Dockerfile b/Dockerfile index 73e6937..2bce07c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/scripts/cibuild.sh b/scripts/cibuild.sh new file mode 100644 index 0000000..3bc03a5 --- /dev/null +++ b/scripts/cibuild.sh @@ -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 + + diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 0000000..282108b --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +zef test . +