update a test with the new pattern #123
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: Java Maven Build, Test, and Publish | |
on: | |
push: | |
branches: | |
- feature* | |
- bugfix* | |
- develop | |
tags: [ 'v.*.*.*' ] | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
maven-build: | |
name: Maven Build and Test | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Install linux deps | |
run: sudo apt-get install -y libcurl4-openssl-dev | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install python dependencies | |
run: pip install jep==3.9 # Install the jep library | |
- name: Set JEP_LIBRARY_PATH environment variable | |
run: | | |
echo "JEP_LIBRARY_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')/jep" >> $GITHUB_ENV | |
- name: test | |
run: | | |
echo $JEP_LIBRARY_PATH | |
ls $JEP_LIBRARY_PATH | |
- name: Install deps | |
run: Rscript -e 'install.packages(c("httr", "jsonlite", "remotes"))' | |
- name: Install metadig | |
run: Rscript -e 'remotes::install_github("nceas/metadig-r")' | |
- name: Extract Maven project version | |
run: echo "version="$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT | |
id: get_version | |
#- name: Show extracted Maven project version | |
#run: echo "Version from pom: " ${{ steps.get_version.outputs.version }} | |
- name: Build and Test | |
run: mvn --batch-mode --update-snapshots test | |
- name: Package | |
run: mvn --batch-mode --update-snapshots -DskipTests=true package | |
- uses: actions/cache@v3 | |
with: | |
path: . | |
key: builddir-${{ github.run_id }} | |
docker-publish: | |
name: Docker Build and Publish | |
if: github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref_name, 'bugfix') | |
needs: maven-build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/cache@v3 | |
with: | |
path: . | |
key: builddir-${{ github.run_id }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# SCHEDULER Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata for scheduler | |
id: metasched | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/nceas/metadig-scheduler | |
# SCHEDULER Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push scheduler image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Docker/metadig-scheduler/Dockerfile | |
build-args: | | |
TAG=${{ steps.metasched.outputs.labels['org.opencontainers.image.version'] }} | |
ENGINE_TAG=${{needs.maven-build.outputs.version}} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.metasched.outputs.tags }} | |
labels: ${{ steps.metasched.outputs.labels }} | |
# SCORER Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata for scorer | |
id: metascor | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/nceas/metadig-scorer | |
# SCORER Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push scorer image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Docker/metadig-scorer/Dockerfile | |
build-args: | | |
TAG=${{ steps.metascor.outputs.labels['org.opencontainers.image.version'] }} | |
ENGINE_TAG=${{needs.maven-build.outputs.version}} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.metascor.outputs.tags }} | |
labels: ${{ steps.metascor.outputs.labels }} | |
# WORKER Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata for worker | |
id: metawor | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/nceas/metadig-worker | |
# WORKER Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push worker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Docker/metadig-worker/Dockerfile | |
build-args: | | |
TAG=${{ steps.metawor.outputs.labels['org.opencontainers.image.version'] }} | |
ENGINE_TAG=${{needs.maven-build.outputs.version}} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.metawor.outputs.tags }} | |
labels: ${{ steps.metawor.outputs.labels }} |