Merge pull request #1 from UniversityofWarwick/SBTWO-12473 #18
This file contains hidden or 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: Build and Publish Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - tomcat-10 | |
| paths-ignore: | |
| - "*.md" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| version: | |
| - 9-jdk8 | |
| - 9-jdk8-oracle | |
| - 9-jdk17 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Select logging library | |
| run: | | |
| # if matrix version is jdk8, set variable to warwick-logging-1.1-all.jar | |
| # else use warwick-logging-1.4.jar | |
| if [ "${{ matrix.version }}" = "9-jdk8" ]; then | |
| echo "Using old logging library for Tomcat 9 with JDK 8" >> $GITHUB_STEP_SUMMARY | |
| echo "LOGGING_LIB=warwick-logging-1.1-all.jar" >> $GITHUB_ENV | |
| else | |
| echo "Using newer logging library" >> $GITHUB_STEP_SUMMARY | |
| echo "LOGGING_LIB=warwick-logging-1.4-all.jar" >> $GITHUB_ENV | |
| fi | |
| - name: Calculate source image tag | |
| run: | | |
| # Remove -oracle from matrix version if it exists and put in env var | |
| SOURCE_IMAGE_TAG=$(echo "${{ matrix.version }}" | sed 's/-oracle//') | |
| echo "SOURCE_IMAGE_TAG=${SOURCE_IMAGE_TAG}" >> $GITHUB_ENV | |
| - name: Prune Oracle library | |
| run: | | |
| # if matrix version doesn't contain oracle, delete tomcat/lib/ojdbc*.jar | |
| if [[ "${{ matrix.version }}" != *"oracle"* ]]; then | |
| echo "Removing Oracle library" >> $GITHUB_STEP_SUMMARY | |
| rm -f tomcat/lib/ojdbc*.jar | |
| fi | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| build-args: | | |
| TOMCAT_VERSION=${{ env.SOURCE_IMAGE_TAG }} | |
| LOGGING_LIB=${{ env.LOGGING_LIB }} | |
| tags: universityofwarwick/dev-tomcat:${{ matrix.version }} |