feat(ci): automate build #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Dev containers for HSG | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 0/12 * * *" | |
env: | |
TEST_TAG: joewiz/hsg-project:exist-ci | |
# EXIST_VER: 6.2.0 | |
jobs: | |
build: | |
name: Build and Test Images | |
runs-on: ubuntu-latest | |
# NOTE (DP): Test on PRs and pushes | |
if: github.ref == 'refs/heads/main' || github.base_ref == 'main' | |
steps: | |
# SETUP | |
- name: Maximize build space | |
uses: easimon/maximize-build-space@master | |
with: | |
build-mount-path: /var/lib/docker/ | |
remove-dotnet: 'true' | |
remove-android: 'true' | |
remove-haskell: 'true' | |
remove-codeql: 'true' | |
remove-docker-images: 'true' | |
- name: Restart docker | |
run: sudo service docker restart | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
# platforms: all | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Make buildkit default | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
with: | |
install: true | |
- name: Install bats | |
# run: sudo apt-get install bats | |
run: sudo apt-get install bats | |
# BUILD | |
- name: Build default images for testing on CI | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
build-args: | | |
TEMPLATING_VERSION=1.1.0 | |
TEI_PUBLISHER_LIB_VERSION=2.10.1 | |
EXPATH_CRYPTO_VERSION=6.0.1 | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
# TEST | |
- name: Start exist-ci containers | |
run: | | |
docker run -dit -p 8080:8080 --name exist --rm ${{ env.TEST_TAG }} | |
- name: wait for install to finish | |
timeout-minutes: 30 | |
run: | | |
while ! docker logs exist | grep -q "Server has started"; \ | |
do sleep 2s; \ | |
done | |
- name: Run tests | |
run: bats --tap test/bats/*.bats | |
# PUSH | |
# Release | |
- name: Push :release to Dockerhub | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
platforms: linux/amd64,linux/arm64 | |
file: ./Dockerfile | |
build-args: | | |
TEMPLATING_VERSION=1.1.0 | |
TEI_PUBLISHER_LIB_VERSION=2.10.1 | |
EXPATH_CRYPTO_VERSION=6.0.1 | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: joewiz/hsg-project:latest | |
cache-from: type=registry,ref=joewiz/hsg-project:buildcache | |
cache-to: type=registry,ref=joewiz/hsg-project:buildcache,mode=max |