diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df43ece1..72acd95d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,7 @@ name: CI on: - push: - branches: [ master ] + push: {} pull_request: branches: [ master ] @@ -60,28 +59,61 @@ jobs: deploy: name: Deploy needs: test - if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: Push helm-operator image to Quay - uses: docker/build-push-action@v1 + - name: Prepare + id: prep + run: | + HELM_OPERATOR_IMAGE=quay.io/joelanford/helm-operator + NGINX_OPERATOR_IMAGE=quay.io/joelanford/nginx-operator + + VERSION=ci + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + elif [[ $GITHUB_REF == refs/pull/* ]]; then + VERSION=pr-${{ github.event.number }} + fi + + HELM_OPERATOR_TAGS="${HELM_OPERATOR_IMAGE}:${VERSION}" + NGINX_OPERATOR_TAGS="${NGINX_OPERATOR_IMAGE}:${VERSION}" + + echo ::set-output name=helm-operator-tags::${HELM_OPERATOR_TAGS} + echo ::set-output name=nginx-operator-tags::${NGINX_OPERATOR_TAGS} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Quay + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 with: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} registry: quay.io - repository: joelanford/helm-operator - tags: master - - name: Push example nginx-operator image to Quay - uses: docker/build-push-action@v1 + - name: Build and push helm-operator + uses: docker/build-push-action@v2 with: - path: example/ - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_PASSWORD }} - registry: quay.io - repository: joelanford/nginx-operator - tags: latest + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x + push: github.event_name != 'pull_request' + tags: ${{ steps.prep.outputs.helm-operator-tags }} + + - name: Build and push example nginx-operator + uses: docker/build-push-action@v2 + with: + context: ./example/ + file: ./Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x + push: github.event_name != 'pull_request' + tags: ${{ steps.prep.outputs.nginx-operator-tags }}