Upgrade JDK to 21 version #34
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: Java CI with Maven and Docker publish | |
| on: | |
| push: | |
| branches: [ master ] | |
| tags: | |
| - v* | |
| pull_request: | |
| branches: [ master ] | |
| env: | |
| IMAGE_NAME_HUB: andrzejsydor/demo-xss | |
| IMAGE_NAME: demo-xss | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: 21 | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Build image | |
| run: docker build . --file Dockerfile --tag $IMAGE_NAME_HUB | |
| - name: Log into registry | |
| run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u andrzejsydor --password-stdin | |
| - name: Push image | |
| run: | | |
| # 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" == "master" ] && VERSION=latest | |
| echo IMAGE_NAME_HUB=$IMAGE_NAME_HUB | |
| VERSION=$(date +%s) | |
| echo $VERSION | |
| docker tag $IMAGE_NAME_HUB $IMAGE_NAME_HUB:$VERSION | |
| docker push $IMAGE_NAME_HUB:$VERSION | |
| docker tag $IMAGE_NAME_HUB $IMAGE_NAME_HUB:latest | |
| docker push $IMAGE_NAME_HUB:latest | |
| push-packages: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v1 | |
| with: | |
| java-version: 21 | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml | |
| - name: Build image | |
| run: docker build . --file Dockerfile --tag $IMAGE_NAME | |
| - name: Log into registry | |
| run: echo "${{ secrets.CI_GITHUB }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
| - name: Push image | |
| run: | | |
| IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME | |
| # Change all uppercase to lowercase | |
| IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
| # 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" == "master" ] && VERSION=latest | |
| echo IMAGE_ID=$IMAGE_ID | |
| echo VERSION=$VERSION | |
| docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
| docker push $IMAGE_ID:$VERSION |