diff --git a/.github/workflows/docker-multiplatform-tag.yml b/.github/workflows/docker-multiplatform-tag.yml new file mode 100644 index 0000000..0e05fce --- /dev/null +++ b/.github/workflows/docker-multiplatform-tag.yml @@ -0,0 +1,69 @@ +--- +name: 'Build Docker On Tag' + +on: + push: + branches: + - bigip-server + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: # Allows manual triggering from the GitHub UI + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@v3 + + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} + + # If this is a git tag, use the tag name as a docker tag + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + TAGS="${DOCKER_IMAGE}:${VERSION}" + fi + + # If this is a git branch, use the branch name as a docker tag + if [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=${GITHUB_REF#refs/heads/} + TAGS="${DOCKER_IMAGE}:${VERSION}" + fi + + # If the VERSION looks like a version number, also tag as 'latest' + if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:latest" + fi + + # Set output parameters + echo ::set-output name=tags::${TAGS} + echo ::set-output name=docker_image::${DOCKER_IMAGE} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build + uses: docker/build-push-action@v4 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le + push: true + tags: ${{ steps.prep.outputs.tags }}