|
| 1 | +name: percona-xtradb-cluster-operator |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - '.github/workflows/percona-xtradb-cluster-operator.yml' |
| 7 | + - 'build/percona-xtradb-cluster-operator/**' |
| 8 | + - '!build/percona-xtradb-cluster-operator/*.md' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Prepare |
| 18 | + id: prep |
| 19 | + run: | |
| 20 | + BASE_DIR=build/percona-xtradb-cluster-operator |
| 21 | + VERSION=$(cat ${BASE_DIR}/.version) |
| 22 | + GIT_COMMIT=$(git rev-parse --short HEAD) |
| 23 | + GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 24 | + BUILD_TIME=$(date '+%FT%TZ') |
| 25 | + echo ::set-output name=version::${VERSION} |
| 26 | + echo ::set-output name=git_commit::${GIT_COMMIT} |
| 27 | + echo ::set-output name=git_branch::${GIT_BRANCH} |
| 28 | + echo ::set-output name=build_time::${BUILD_TIME} |
| 29 | + echo ::set-output name=base_dir::${BASE_DIR} |
| 30 | +
|
| 31 | + - name: Set up QEMU |
| 32 | + uses: docker/setup-qemu-action@v1 |
| 33 | + with: |
| 34 | + platforms: all |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + id: buildx |
| 38 | + uses: docker/setup-buildx-action@v1 |
| 39 | + with: |
| 40 | + install: true |
| 41 | + version: latest |
| 42 | + |
| 43 | + - name: Login to DockerHub |
| 44 | + uses: docker/login-action@v1 |
| 45 | + with: |
| 46 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 47 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 48 | + |
| 49 | + - name: Build and Push |
| 50 | + if: github.ref != 'refs/heads/main' |
| 51 | + uses: docker/build-push-action@v2 |
| 52 | + with: |
| 53 | + build-args: | |
| 54 | + VERSION=${{ steps.prep.outputs.version }} |
| 55 | + GIT_COMMIT=${{ steps.prep.outputs.git_commit }} |
| 56 | + GIT_BRANCH=${{ steps.prep.outputs.git_branch }} |
| 57 | + BUILD_TIME=${{ steps.prep.outputs.build_time }} |
| 58 | + context: ${{ steps.prep.outputs.base_dir }}/ |
| 59 | + file: ${{ steps.prep.outputs.base_dir }}/Dockerfile |
| 60 | + platforms: linux/amd64,linux/arm/v7,linux/arm64 |
| 61 | + push: true |
| 62 | + tags: | |
| 63 | + raspbernetes/percona-xtradb-cluster-operator:${{ github.sha }} |
| 64 | +
|
| 65 | + - name: Build and Push |
| 66 | + if: github.ref == 'refs/heads/main' |
| 67 | + uses: docker/build-push-action@v2 |
| 68 | + with: |
| 69 | + build-args: | |
| 70 | + VERSION=${{ steps.prep.outputs.version }} |
| 71 | + GIT_COMMIT=${{ steps.prep.outputs.git_commit }} |
| 72 | + GIT_BRANCH=${{ steps.prep.outputs.git_branch }} |
| 73 | + BUILD_TIME=${{ steps.prep.outputs.build_time }} |
| 74 | + context: ${{ steps.prep.outputs.base_dir }}/ |
| 75 | + file: ${{ steps.prep.outputs.base_dir }}/Dockerfile |
| 76 | + platforms: linux/amd64,linux/arm/v7,linux/arm64 |
| 77 | + push: true |
| 78 | + tags: | |
| 79 | + raspbernetes/percona-xtradb-cluster-operator:latest |
| 80 | + raspbernetes/percona-xtradb-cluster-operator:${{ steps.prep.outputs.version }} |
0 commit comments