diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index dee1354..a67e3e8 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -35,8 +35,7 @@ jobs: build-v1-26-0-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.26.0-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.26.0-alpine-3.8 + VARIANT: v1.26.0-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -60,96 +59,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} ${{ github.repository }}:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -162,18 +153,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-26-0-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -197,96 +180,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.26.0-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -298,18 +273,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-25-5-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.25.5-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.25.5-alpine-3.8 + VARIANT: v1.25.5-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -333,96 +300,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -434,18 +393,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-25-5-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -469,96 +420,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.25.5-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -570,18 +513,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-24-9-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.24.9-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.24.9-alpine-3.8 + VARIANT: v1.24.9-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -605,96 +540,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -706,18 +633,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-24-9-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -741,96 +660,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.24.9-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -842,18 +753,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-23-15-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.23.15-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.23.15-alpine-3.8 + VARIANT: v1.23.15-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -877,96 +780,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -978,18 +873,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-23-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1013,96 +900,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.23.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1114,18 +993,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-22-17-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.22.17-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.22.17-alpine-3.8 + VARIANT: v1.22.17-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1149,96 +1020,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1250,18 +1113,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-22-17-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1285,96 +1140,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.22.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1386,18 +1233,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-21-14-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.21.14-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.21.14-alpine-3.8 + VARIANT: v1.21.14-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1421,96 +1260,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1522,18 +1353,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-21-14-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1557,96 +1380,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.21.14-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1658,18 +1473,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-20-15-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.20.15-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.20.15-alpine-3.8 + VARIANT: v1.20.15-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1693,96 +1500,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1794,18 +1593,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-20-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1829,96 +1620,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.20.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -1930,18 +1713,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-19-16-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.19.16-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.19.16-alpine-3.8 + VARIANT: v1.19.16-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -1965,96 +1740,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2066,18 +1833,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-19-16-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2101,96 +1860,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.19.16-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2202,18 +1953,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-18-20-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.18.20-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.18.20-alpine-3.8 + VARIANT: v1.18.20-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2237,96 +1980,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2338,18 +2073,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-18-20-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2373,96 +2100,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.18.20-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2474,18 +2193,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-17-17-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.17.17-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.17.17-alpine-3.8 + VARIANT: v1.17.17-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2509,96 +2220,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2610,18 +2313,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-17-17-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2645,96 +2340,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.17.17-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2746,18 +2433,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-16-15-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.16.15-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.16.15-alpine-3.8 + VARIANT: v1.16.15-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2781,96 +2460,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -2882,18 +2553,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-16-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -2917,96 +2580,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.16.15-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -3018,18 +2673,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-15-12-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.15.12-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.15.12-alpine-3.8 + VARIANT: v1.15.12-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -3053,96 +2700,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -3154,18 +2793,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-15-12-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -3189,96 +2820,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.15.12-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -3290,18 +2913,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-14-10-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.14.10-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.14.10-alpine-3.8 + VARIANT: v1.14.10-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -3325,96 +2940,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -3426,18 +3033,10 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - build-v1-14-10-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8: runs-on: ubuntu-latest env: - VARIANT_TAG: v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 - VARIANT_BUILD_DIR: variants/v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 + VARIANT: v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 steps: - name: Checkout uses: actions/checkout@v3 @@ -3461,96 +3060,88 @@ jobs: - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: false tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: ${{ env.VARIANT_BUILD_DIR }} + context: variants/v1.14.10-envsubst-git-jq-kustomize-sops-ssh-alpine-3.8 platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x push: true tags: | - ${{ github.repository }}:${{ env.VARIANT_TAG }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:${{ env.VARIANT }} + ${{ github.repository }}:${{ env.REF_VARIANT }} + ${{ github.repository }}:${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max @@ -3562,13 +3153,6 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() - update-draft-release: needs: [build-v1-26-0-alpine-3-8, build-v1-26-0-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-25-5-alpine-3-8, build-v1-25-5-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-24-9-alpine-3-8, build-v1-24-9-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-23-15-alpine-3-8, build-v1-23-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-22-17-alpine-3-8, build-v1-22-17-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-21-14-alpine-3-8, build-v1-21-14-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-20-15-alpine-3-8, build-v1-20-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-19-16-alpine-3-8, build-v1-19-16-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-18-20-alpine-3-8, build-v1-18-20-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-17-17-alpine-3-8, build-v1-17-17-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-16-15-alpine-3-8, build-v1-16-15-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-15-12-alpine-3-8, build-v1-15-12-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8, build-v1-14-10-alpine-3-8, build-v1-14-10-envsubst-git-jq-kustomize-sops-ssh-alpine-3-8] if: github.ref == 'refs/heads/master' diff --git a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 index 320a821..c7dc1fb 100644 --- a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 +++ b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 @@ -42,8 +42,7 @@ $VARIANTS | % { build-$( $_['tag'].Replace('.', '-') ): runs-on: ubuntu-latest env: - VARIANT_TAG: $( $_['tag'] ) - VARIANT_BUILD_DIR: $( $_['build_dir_rel'] ) + VARIANT: $( $_['tag'] ) "@ @' @@ -70,99 +69,91 @@ $VARIANTS | % { - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- + ${{ runner.os }}-buildx-${{ env.VARIANT }}- ${{ runner.os }}-buildx- + # This step generates the docker tags - name: Prepare id: prep run: | set -e - # Get 'namespace' and 'project-name' from 'namespace/project-name' - # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) - # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) - - # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v1.2.3' + # Get ref, i.e. from refs/heads/, or from refs/tags/. E.g. 'master' or 'v0.0.0' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - # Get commit hash E.g. 'b29758a' - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) + # Get short commit hash E.g. 'abc0123' + SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-mytag' and 'master-b29758a-mytag' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" + # Generate docker image tags + # E.g. 'v0.0.0-' and 'v0.0.0-abc0123-' + # E.g. 'master-' and 'master-abc0123-' + REF_VARIANT="${REF}-${VARIANT}" + REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}" # Pass variables to next step - # echo "CI_PROJECT_NAMESPACE=$CI_PROJECT_NAMESPACE" >> $GITHUB_ENV - # echo "CI_PROJECT_NAME=$CI_PROJECT_NAME" >> $GITHUB_ENV - # echo "REF=$REF" >> $GITHUB_ENV - # echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV - # echo "REF_AND_SHA_SHORT=$REF_AND_SHA_SHORT" >> $GITHUB_ENV echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_ENV - echo "VARIANT_TAG=$VARIANT_TAG" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF=$VARIANT_TAG_WITH_REF" >> $GITHUB_ENV - echo "VARIANT_TAG_WITH_REF_AND_SHA_SHORT=$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" >> $GITHUB_ENV + echo "VARIANT=$VARIANT" >> $GITHUB_ENV + echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_ENV + echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_ENV - - name: Login to docker registry + - name: Login to Docker Hub registry + # Run on master and tags if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} '@ @" - name: Build (PRs) - id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 with: - context: `${{ env.VARIANT_BUILD_DIR }} + context: $( $_['build_dir_rel'] ) platforms: $( $_['_metadata']['platforms'] -join ',' ) push: false tags: | - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF }} - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ env.REF_VARIANT }} + `${{ github.repository }}:`${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) - id: docker_build_master # Run only on master if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v3 with: - context: `${{ env.VARIANT_BUILD_DIR }} + context: $( $_['build_dir_rel'] ) platforms: $( $_['_metadata']['platforms'] -join ',' ) push: true tags: | - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF }} - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ env.REF_VARIANT }} + `${{ github.repository }}:`${{ env.REF_SHA_VARIANT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) - id: docker_build_release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v3 with: - context: `${{ env.VARIANT_BUILD_DIR }} + context: $( $_['build_dir_rel'] ) platforms: $( $_['_metadata']['platforms'] -join ',' ) push: true tags: | - `${{ github.repository }}:`${{ env.VARIANT_TAG }} - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF }} - `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ env.VARIANT }} + `${{ github.repository }}:`${{ env.REF_VARIANT }} + `${{ github.repository }}:`${{ env.REF_SHA_VARIANT }} "@ @@ -183,13 +174,6 @@ if ( $_['tag_as_latest'] ) { run: | rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - - name: List docker images - run: docker images - - - name: Clean-up - run: docker logout - if: always() '@ }