Release #14
Workflow file for this run
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: Release | |
| on: | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| REPOSITORY: ${{ github.repository }} | |
| IMAGES: >- | |
| [{ | |
| 'name': 'radar-appserverradar-upload-backend', | |
| 'build_file': 'Dockerfile', | |
| 'authors': 'Yatharth Ranjan <yatharth.ranjan@kcl.ac.uk>, Pauline Conde <pauline.conde@kcl.ac.uk>', | |
| 'description': 'RADAR-base appserver backend application', | |
| 'cache_keys_files': ['Dockerfile', '**/*.gradle.kts', 'gradle.properties', 'src/main/**'] | |
| }] | |
| jobs: | |
| upload: | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Compile code | |
| run: ./gradlew assemble | |
| - name: Upload to GitHub | |
| uses: AButler/upload-release-assets@v3.0 | |
| with: | |
| files: 'build/libs/*' | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| prepare-matrix: | |
| name: Prepare Matrix Output | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| outputs: | |
| images: ${{ steps.step1.outputs.matrix }} | |
| steps: | |
| - name: Create Matrix Variable | |
| id: step1 | |
| run: echo "matrix=${{ env.IMAGES }}" >> $GITHUB_OUTPUT | |
| docker: | |
| needs: prepare-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| image: ${{ fromJson(needs.prepare-matrix.outputs.images ) }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # Setup docker build environment | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lowercase image name | |
| run: | | |
| echo "DOCKER_IMAGE=${REGISTRY}/${REPOSITORY,,}/${{ matrix.image.name }}" >>${GITHUB_ENV} | |
| # Add Docker labels and tags | |
| - name: Docker meta | |
| id: docker_meta | |
| uses: docker/metadata-action@v4 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=match,pattern=v(.*),group=1 | |
| - name: Build backend docker and push | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: . | |
| file: ${{ matrix.image.build_file }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.docker_meta.outputs.tags }} | |
| labels: | | |
| ${{ steps.docker_meta.outputs.labels }} | |
| maintainer=${{ matrix.image.authors }} | |
| org.opencontainers.image.description=${{ matrix.image.description }} | |
| org.opencontainers.image.authors=${{ matrix.image.authors }} | |
| org.opencontainers.image.vendor=RADAR-base | |
| org.opencontainers.image.licenses=Apache-2.0 | |
| - name: Inspect docker image | |
| run: | | |
| docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} | |
| docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} |