|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 9 | + - "[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" |
| 10 | + - "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" |
| 11 | + - "[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" |
| 12 | + - "[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" |
| 13 | + |
| 14 | +env: |
| 15 | + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 |
| 16 | + |
| 17 | +jobs: |
| 18 | + docker: |
| 19 | + name: Docker |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Set up QEMU |
| 26 | + uses: docker/setup-qemu-action@v1 |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v1 |
| 29 | + - name: Cache Docker layers |
| 30 | + uses: actions/cache@v2 |
| 31 | + with: |
| 32 | + path: /tmp/.buildx-cache |
| 33 | + key: ${{ runner.os }}-buildx-${{ github.ref }} |
| 34 | + restore-keys: | |
| 35 | + ${{ runner.os }}-buildx- |
| 36 | +
|
| 37 | + - name: Login to GitHub Container Registry |
| 38 | + uses: docker/login-action@v1 |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + username: ${{ github.repository_owner }} |
| 42 | + password: ${{ secrets.CR_PAT }} |
| 43 | + |
| 44 | + - name: Login to DockerHub |
| 45 | + uses: docker/login-action@v2 |
| 46 | + with: |
| 47 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 48 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 49 | + |
| 50 | + - name: Determine tag or commit |
| 51 | + uses: haya14busa/action-cond@v1 |
| 52 | + id: refortag |
| 53 | + with: |
| 54 | + cond: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 55 | + if_true: ${{ github.ref }} |
| 56 | + if_false: latest |
| 57 | + |
| 58 | + - name: Determine image tag |
| 59 | + id: imagetag |
| 60 | + run: echo "::set-output name=value::${TAG_OR_BRANCH##*/}" |
| 61 | + env: |
| 62 | + TAG_OR_BRANCH: ${{ steps.refortag.outputs.value }} |
| 63 | + |
| 64 | + - name: Build allspark |
| 65 | + uses: docker/build-push-action@v3 |
| 66 | + with: |
| 67 | + file: Dockerfile |
| 68 | + platforms: linux/amd64 |
| 69 | + push: true |
| 70 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 71 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 72 | + tags: | |
| 73 | + ghcr.io/banzaicloud/allspark:${{ steps.imagetag.outputs.value }} |
| 74 | + banzaicloud/allspark:${{ steps.imagetag.outputs.value }} |
0 commit comments