Build basex-validator image on Github and push to GHCR #8
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
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
push: | |
branches: | |
- master | |
jobs: | |
generate-version: | |
runs-on: ubuntu-latest | |
outputs: | |
trunkver: ${{ steps.trunkver.outputs.trunkver }} | |
steps: | |
- name: Get a version tag | |
id: trunkver | |
uses: crftd-tech/trunkver@main | |
with: | |
prerelease: ${{ github.ref == 'refs/heads/master' && 'false' || 'true' }} | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up Docker | |
uses: docker/setup-docker-action@v4 | |
with: | |
daemon-config: | | |
{ | |
"debug": true, | |
"features": { | |
"containerd-snapshotter": true | |
} | |
} | |
- name: Build and load image | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Bring up test stack | |
run: docker compose up --wait | |
- name: Debug bring up test stack | |
if: failure() | |
run: docker compose logs | |
- name: Project Tests | |
run: (cd test &&./smoke_tests_wsgi.sh); cd .. | |
build-and-push: | |
needs: [generate-version, tests] | |
runs-on: ubuntu-latest | |
# if: github.ref == 'refs/heads/master' | |
env: | |
IMAGE_REPO: ghcr.io/elifesciences/basex-validator | |
IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && needs.generate-version.outputs.trunkver || format('{0}-{1}', github.head_ref || github.ref_name, needs.generate-version.outputs.trunkver) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
load: false | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
${{ env.IMAGE_REPO }}:${{ github.sha }} | |
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} |