|
| 1 | +name: Publish Docker Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version tag for docker images (e.g. 25.12)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + push: |
| 11 | + description: 'Push images to Docker Hub' |
| 12 | + required: true |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + latest: |
| 16 | + description: 'Also tag openjdk18-bullseye-spring as latest' |
| 17 | + required: true |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + framework: [spring, dropwizard] |
| 28 | + jdk: [openjdk8, openjdk11, openjdk18] |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Set up Docker Buildx |
| 34 | + uses: docker/setup-buildx-action@v3 |
| 35 | + |
| 36 | + - name: Login to Docker Hub |
| 37 | + if: ${{ inputs.push }} |
| 38 | + uses: docker/login-action@v3 |
| 39 | + with: |
| 40 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 41 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Set context directory |
| 44 | + id: ctx |
| 45 | + run: | |
| 46 | + if [ "${{ matrix.framework }}" = "spring" ]; then |
| 47 | + echo "dir=Demos/Spring" >> "$GITHUB_OUTPUT" |
| 48 | + else |
| 49 | + echo "dir=Demos/Dropwizard" >> "$GITHUB_OUTPUT" |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Determine tags |
| 53 | + id: tags |
| 54 | + run: | |
| 55 | + TAG="groupdocs/viewer:${{ inputs.version }}-java-${{ matrix.jdk }}-bullseye-${{ matrix.framework }}" |
| 56 | + TAGS="${TAG}" |
| 57 | + if [ "${{ inputs.latest }}" = "true" ] && [ "${{ matrix.framework }}" = "spring" ] && [ "${{ matrix.jdk }}" = "openjdk18" ]; then |
| 58 | + TAGS="${TAGS},groupdocs/viewer:latest" |
| 59 | + fi |
| 60 | + echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" |
| 61 | +
|
| 62 | + - name: Build and push |
| 63 | + uses: docker/build-push-action@v6 |
| 64 | + with: |
| 65 | + context: ${{ steps.ctx.outputs.dir }} |
| 66 | + file: ${{ steps.ctx.outputs.dir }}/docker/Dockerfile-${{ matrix.jdk }}-bullseye |
| 67 | + push: ${{ inputs.push }} |
| 68 | + tags: ${{ steps.tags.outputs.tags }} |
| 69 | + cache-from: type=gha |
| 70 | + cache-to: type=gha,mode=max |
0 commit comments