|
7 | 7 | - v*
|
8 | 8 | jobs:
|
9 | 9 | push_to_registries:
|
10 |
| - name: Push Docker image to Dockerhub and Github |
| 10 | + name: Push Docker image to Dockerhub |
11 | 11 | runs-on: ubuntu-latest
|
| 12 | + env: |
| 13 | + DOCKER_REGISTRY: docker.io |
| 14 | + DOCKER_IMAGE: castyapp/dashboard |
| 15 | + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 16 | + DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
| 17 | + DOCKER_TARGET_PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 |
12 | 18 | steps:
|
13 | 19 | - name: Check out the repo
|
14 | 20 | uses: actions/checkout@v2
|
15 |
| - - uses: docker/setup-buildx-action@v1 |
16 |
| - |
17 |
| - - name: Login to DockerHub |
18 |
| - uses: docker/login-action@v1 |
| 21 | + |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: crazy-max/ghaction-docker-buildx@v2 |
19 | 24 | with:
|
20 |
| - username: ${{ secrets.DOCKERHUB_USERNAME }} |
21 |
| - password: ${{ secrets.DOCKERHUB_TOKEN }} |
22 |
| - logout: true |
| 25 | + version: latest |
23 | 26 |
|
24 |
| - - name: Build and Push to Docker Hub |
25 |
| - uses: docker/build-push-action@v2 |
26 |
| - with: |
27 |
| - context: . |
28 |
| - file: ./Dockerfile |
29 |
| - tags: castylab/dashboard:latest |
30 |
| - push: true |
| 27 | + - name: Prepare |
| 28 | + if: success() |
| 29 | + id: prepare |
| 30 | + run: | |
| 31 | + echo ::set-output name=docker_platform::${DOCKER_TARGET_PLATFORM} |
| 32 | + echo ::set-output name=docker_image::${DOCKER_REGISTRY}/${DOCKER_IMAGE} |
| 33 | + echo ::set-output name=release_version::${GITHUB_REF#refs/*/} |
31 | 34 |
|
32 |
| - - name: Build alpine and Push to Docker Hub |
33 |
| - uses: docker/build-push-action@v2 |
34 |
| - with: |
35 |
| - context: . |
36 |
| - file: ./Dockerfile |
37 |
| - tags: castylab/dashboard:alpine |
38 |
| - push: true |
| 35 | + - name: Login to DockerHub |
| 36 | + if: success() |
| 37 | + run: | |
| 38 | + echo "${DOCKER_TOKEN}" | docker login ${DOCKER_REGISTRY} --username "${DOCKER_USERNAME}" --password-stdin |
| 39 | +
|
| 40 | + - name: Run Buildx (push image) |
| 41 | + if: success() |
| 42 | + run: | |
| 43 | + docker buildx build \ |
| 44 | + --platform ${{ steps.prepare.outputs.docker_platform }} \ |
| 45 | + --tag ${{ steps.prepare.outputs.docker_image }}:latest \ |
| 46 | + --tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.release_version }} \ |
| 47 | + --file ./Dockerfile \ |
| 48 | + --output type=image,push=true . |
0 commit comments