diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a5798e870f8..e93700ef64f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,16 +4,11 @@ name: Docker # # Summary # -# job docker-branch-os-matrix: -# * creates tags latest-alpine, latest-debian and latest-ubuntu for main branch -# * creates tags stable-alpine, stable-debian and stable-ubuntu for releasebranch_8_2 -# * creates tags -alpine, -debian and -ubuntu for all triggered branches -# -# job docker-main-latest: -# * creates tag latest for main branch -# -# job docker-release-os-matrix: +# job docker-os-matrix: # * creates tags -alpine, -debian and -ubuntu for each release +# * creates tags -alpine, -debian and -ubuntu for all triggered branches +# * creates tags current-alpine, current-debian and current-ubuntu for releasebranch_8_3 +# * creates tag latest for last stable release with ubuntu os on: @@ -22,129 +17,27 @@ on: - main - releasebranch_* - '!releasebranch_7_*' - tags: ['*.*.*'] + # tags: ['*.*.*'] paths-ignore: [doc/**] release: types: [published] -env: - # Additionally mentioned in docker-sha-release-latest - # as use of variable fails there - DOCKERHUB_REPOSITORY: osgeo/grass-gis - jobs: - # Only run for push to configured branches, do not run for releases. - # Take care of different os. For main branch, created tags are: - # latest-alpine, latest-debian, latest-ubuntu - # For releasebranch_8_2, created tags are: - # stable-alpine, stable-debian, stable-ubuntu - docker-branch-os-matrix: - name: build and push ${{ matrix.os }} for branch - if: startsWith(github.ref, 'refs/heads/') && github.repository_owner == 'OSGeo' - runs-on: ubuntu-latest - - strategy: - matrix: - os: - - alpine - - debian - - ubuntu - fail-fast: false - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: meta - name: Create tag name - run: | - if [ "$GITHUB_REF" == "refs/heads/main" ] - then - TAG_PREFIX=latest - elif [ "$GITHUB_REF" == "refs/heads/releasebranch_8_2" ] - then - TAG_PREFIX=stable - else - # use branch name as TAG_PREFIX - TAG_PREFIX=`echo $GITHUB_REF|cut -d '/' -f3` - fi - tag="${DOCKERHUB_REPOSITORY}:${TAG_PREFIX}-${{ matrix.os }}" - echo "tags=$tag" >> $GITHUB_OUTPUT - - name: Log - run: | - echo ${{ steps.meta.outputs.tags }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v4 - with: - push: true - pull: true - context: . - tags: ${{ steps.meta.outputs.tags }} - file: docker/${{ matrix.os }}/Dockerfile - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} - - - # Only run for push to main branch - # Take care of tag latest - # This job needs to build the configured image (ubuntu) - # again for main branch to create latest tag. - docker-main-latest: - name: build and push latest for main branch - if: github.ref == 'refs/heads/main' && github.repository_owner == 'OSGeo' + # Run for push to configured branches and all published releases. + # Take care of different os. + # For main branch, created tags are: + # main-alpine, main-debian, main-ubuntu + # For releasebranch_8_3, created tags are: + # current-alpine, current-debian, current-ubuntu, + # releasebranch_8_3-alpine, releasebranch_8_3-debian, releasebranch_8_3-ubuntu + # For a release, e.g. 8.3.0, created tags are: + # 8.3.0-alpine, 8.3.0-debian, 8.3.0-ubuntu and latest (with ubuntu) + docker-os-matrix: + name: build and push ${{ matrix.os }} for ${{ github.ref }} + if: github.repository_owner == 'OSGeo' runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - id: meta - name: Create tag name - run: | - tag=${DOCKERHUB_REPOSITORY}:latest - echo "tags=$tag" >> $GITHUB_OUTPUT - - name: Log - run: echo ${{ steps.meta.outputs.tags }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - id: docker_build - uses: docker/build-push-action@v4 - with: - push: true - pull: true - context: . - tags: ${{ steps.meta.outputs.tags }} - file: docker/ubuntu/Dockerfile - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} - - - # run for releases, take care of release tags - docker-release-os-matrix: - name: build and push release for ${{ matrix.os }} - if: startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'OSGeo' - runs-on: ubuntu-latest strategy: matrix: os: @@ -158,24 +51,19 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Create image and tag name + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: - # images: ${DOCKERHUB_REPOSITORY} images: osgeo/grass-gis tags: | type=ref,event=tag + type=ref,event=branch + type=raw,value=current,enable=${{ github.ref == format('refs/heads/{0}', 'releasebranch_8_3') }} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/8.3') && matrix.os == 'ubuntu' }},suffix= flavor: | latest=false - - id: meta2 - name: Update tag name - run: | - tag="${{ steps.meta.outputs.tags }}-${{ matrix.os }}" - echo "tags=$tag" >> $GITHUB_OUTPUT - - name: Log - run: | - echo ${{ steps.meta2.outputs.tags }} + suffix=-${{ matrix.os }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -192,7 +80,7 @@ jobs: push: true pull: true context: . - tags: ${{ steps.meta2.outputs.tags }} + tags: ${{ steps.meta.outputs.tags }} file: docker/${{ matrix.os }}/Dockerfile - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}