This repository has been archived by the owner on Jan 25, 2025. It is now read-only.
Merge pull request #230 from dofusdude/dependabot/maven/surefire-plug… #101
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 | |
on: | |
push: | |
# Publish `main` as Docker `latest` image. | |
branches: | |
- main | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
env: | |
IMAGE_NAME: almanax-api | |
jobs: | |
# Run tests. | |
# See also https://docs.docker.com/docker-hub/builds/automated-testing/ | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- name: Run tests | |
run: | | |
if [ -f docker-compose.test.yml ]; then | |
docker-compose --file docker-compose.test.yml build | |
docker-compose --file docker-compose.test.yml run sut | |
fi | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
push: | |
# Ensure test job passes before pushing image. | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/[email protected] | |
- name: Build image | |
run: ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true | |
- name: Log into registry | |
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u stelzo --password-stdin | |
- name: Push image | |
run: | | |
IMAGE_ID=runner/$IMAGE_NAME:1.0-SNAPSHOT | |
IMAGE_READY=stelzo/$IMAGE_NAME | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "main" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_ID $IMAGE_READY:$VERSION | |
docker push $IMAGE_READY:$VERSION |