From 497d5c968656bed7aa7568b240e0472501e2763b Mon Sep 17 00:00:00 2001 From: Benny Samir Hierl Date: Sat, 29 Jan 2022 12:09:55 +0100 Subject: [PATCH] Build action for docker added Signed-off-by: Benny Samir Hierl --- .github/workflows/build-publish-image.yml | 56 +++++++++++++++++++++++ package-lock.json | 4 +- package.json | 2 +- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-publish-image.yml diff --git a/.github/workflows/build-publish-image.yml b/.github/workflows/build-publish-image.yml new file mode 100644 index 0000000..bc13a62 --- /dev/null +++ b/.github/workflows/build-publish-image.yml @@ -0,0 +1,56 @@ +name: 'Build and publish docker image' + +on: + push: + branches: [main] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} + VERSION=$(npm pkg get version) + + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" + + # 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@master + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm,linux/arm64 + push: true + tags: ${{ steps.prep.outputs.tags }} diff --git a/package-lock.json b/package-lock.json index 274cafa..23719a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "wishlist", - "version": "0.0.0", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.0.0", + "version": "0.1.0", "dependencies": { "@prisma/client": "^3.8.1", "axios": "^0.25.0", diff --git a/package.json b/package.json index a01574d..bff752f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.0.0", + "version": "0.1.0", "scripts": { "dev": "concurrently --kill-others \"npm run dev:frontend\" \"npm run dev:backend\"", "dev:frontend": "vite",