|
| 1 | +name: Release GeoNode Docker Images |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: "geonode_build_release" |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +env: |
| 8 | + TITLE: "52°North GeoNode Docker Image" |
| 9 | + VENDOR: "52°North GmbH" |
| 10 | + AUTHORS: "https://52North.org/" |
| 11 | + DESCRIPTION: "Builds and publishes the Docker images GeoNode, GeoServer, Nginx" |
| 12 | + LICENSE: "GPL-3.0" |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + tags: |
| 17 | + - "*-52n" |
| 18 | + |
| 19 | +jobs: |
| 20 | + build_and_push_geonode: |
| 21 | + runs-on: ubuntu-22.04 |
| 22 | + env: |
| 23 | + IMAGE: 52north/geonode |
| 24 | + steps: |
| 25 | + - |
| 26 | + name: Checkout |
| 27 | + uses: actions/checkout@v3 |
| 28 | + - |
| 29 | + name: Parse semver string |
| 30 | + id: semver_parser |
| 31 | + uses: booxmedialtd/ws-action-parse-semver@v1 |
| 32 | + with: |
| 33 | + input_string: "${{github.ref_name}}" |
| 34 | + version_extractor_regex: '(.*)-52n' |
| 35 | + - |
| 36 | + name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v2 |
| 38 | + - |
| 39 | + name: Extract metadata (tags, labels) for Docker |
| 40 | + id: meta |
| 41 | + uses: docker/metadata-action@v4 |
| 42 | + env: |
| 43 | + MAJOR_VERSION: ${{ steps.semver_parser.outputs.major }} |
| 44 | + MAJOR_MINOR_VERSION: ${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }} |
| 45 | + MAJOR_MINOR_PATCH_VERSION: ${{ steps.semver_parser.outputs.fullversion }} |
| 46 | + with: |
| 47 | + images: ${{ env.IMAGE }} |
| 48 | + labels: | |
| 49 | + "org.opencontainers.image.authors=${{ env.AUTHORS }}" |
| 50 | + "org.opencontainers.image.vendor=${{ env.VENDOR }}" |
| 51 | + "org.opencontainers.image.description=${{ env.DESCRIPTION }}" |
| 52 | + "org.opencontainers.image.title=${{ env.TITLE }}" |
| 53 | + "org.opencontainers.image.licenses=${{ env.LICENSE }}" |
| 54 | + tags: | |
| 55 | + latest |
| 56 | + ${{ env.MAJOR_VERSION }} |
| 57 | + ${{ env.MAJOR_MINOR_VERSION }} |
| 58 | + ${{ env.MAJOR_MINOR_PATCH_VERSION }} |
| 59 | + - |
| 60 | + name: Login to Docker Hub |
| 61 | + uses: docker/login-action@v2 |
| 62 | + with: |
| 63 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 64 | + password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }} |
| 65 | + - |
| 66 | + name: Fail in case fully tagged version already exists |
| 67 | + run: | |
| 68 | + if docker manifest inspect ${{ env.IMAGE }}:${{ steps.semver_parser.outputs.fullversion }}; then |
| 69 | + echo "tag version already exists! Will not override." |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + - |
| 73 | + name: Build and push |
| 74 | + if: ${{ !github.event.act }} # skip during local actions testing |
| 75 | + uses: docker/build-push-action@v4 |
| 76 | + with: |
| 77 | + context: . |
| 78 | + file: ./Dockerfile |
| 79 | + push: true |
| 80 | + tags: ${{ steps.meta.outputs.tags }} |
| 81 | + labels: ${{ steps.meta.outputs.labels }} |
| 82 | + cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache |
| 83 | + cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max |
| 84 | + |
0 commit comments