From d282e2e5e66c44fe7fea7f530837aeeffa5c4b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Wed, 1 Sep 2021 03:16:01 +0300 Subject: [PATCH] CI: Login to Docker Hub and other tweaks --- .github/workflows/main.yml | 71 ++++++++++++++++++++++++++++++++++++++ Makefile | 1 - image/Dockerfile | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f1a0910 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +name: Release + +on: + workflow_dispatch: + push: + branches: + - move-to-github-actions + + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci-skip]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/} + VERSION=latest + SHORTREF=${GITHUB_SHA::8} + + # If this is git tag, use the tag name as a docker tag + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" + + # If the VERSION looks like a version number, assume that + # this is the most recent version of the image and also + # tag it 'latest'. + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:latest" + fi + + # 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@v1 + with: + platforms: amd64,arm64 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + version: latest + driver-opts: image=moby/buildkit:latest + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push + uses: docker/build-push-action@v2 + with: + build-args: VERSION=focal-1.0.0-test + builder: ${{ steps.buildx.outputs.name }} + context: image + platforms: amd64,arm64 + push: true + tags: ${{ steps.prep.outputs.tags }} diff --git a/Makefile b/Makefile index 0a78cec..fe24996 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,6 @@ VERSION_ARG ?= $(VERSION) all: build build: - ./build.sh docker build --no-cache -t $(NAME):$(VERSION_ARG) $(BUILD_ARG) --build-arg QEMU_ARCH=$(QEMU_ARCH) --platform $(PLATFORM) --rm image build_multiarch: diff --git a/image/Dockerfile b/image/Dockerfile index 7e074d5..b800988 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_IMAGE=ubuntu:20.04 FROM $BASE_IMAGE ARG QEMU_ARCH -ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin +#ADD x86_64_qemu-${QEMU_ARCH}-static.tar.gz /usr/bin COPY . /bd_build