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/deploy.raku b/deploy.raku deleted file mode 100644 index 90ccbab..0000000 --- a/deploy.raku +++ /dev/null @@ -1,13 +0,0 @@ -my $deployment = slurp('deployment.yaml'); -with $deployment ~~ /':v'(\d+)/ -> (Int() $version is copy) { - $version++; - my $tag = "gcr.io/mystical-banner-176722/app:v$version"; - run 'docker', 'build', '-t', $tag, '.'; - run 'gcloud', 'docker', '--', 'push', $tag; - $deployment ~~ s/':v'(\d+)/:v$version/; - spurt 'deployment.yaml', $deployment; - run 'kubectl', 'apply', '-f', 'deployment.yaml'; -} -else { - die "Could not find version in deployment.yaml"; -} diff --git a/deployment.yaml b/deployment.yaml deleted file mode 100644 index 1ec7b76..0000000 --- a/deployment.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: cro-website-app -spec: - replicas: 1 - selector: - matchLabels: - service: cro-website - tier: backend - template: - metadata: - labels: - service: cro-website - tier: backend - spec: - containers: - - name: cro-website-app - image: "gcr.io/mystical-banner-176722/app:v64" - ports: - - name: http - containerPort: 8080 - resources: - requests: - cpu: 100m 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 . + diff --git a/service.yaml b/service.yaml deleted file mode 100644 index 2196cbc..0000000 --- a/service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - name: cro-website-app -spec: - selector: - service: cro-website - tier: backend - ports: - - protocol: TCP - port: 8080 - targetPort: http