From e07a5b606597e2636e19173aac2e65a4416b37df Mon Sep 17 00:00:00 2001 From: bahetiamit Date: Thu, 5 Nov 2020 18:46:36 -0800 Subject: [PATCH] Adding github action on release to publish multi-arch image --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ scripts/check.sh | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4a67070 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Publish image to Dockerhub + +on: + release: + types: [released] + +jobs: + build: + env: + IMAGE_NAME: mikefarah/yq + runs-on: ubuntu-latest + steps: + - name: Get latest release tag + uses: oprypin/find-latest-tag@v1 + with: + repository: mikefarah/yq # The repository to scan. + releases-only: true # We know that all relevant tags have a GitHub release for them. + id: yq + + - name: Clone source code + uses: actions/checkout@v2 + with: + ref: ${{ steps.yq.outputs.tag }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} && docker version + + - name: Build and push image + run: | + IMAGE_VERSION="$(git describe --tags --abbrev=0)" + SHORT_SHA1=$(git rev-parse --short HEAD) + PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" + echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" + echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + docker buildx build --platform "${PLATFORMS}" -t "${IMAGE_NAME}:${IMAGE_VERSION}" -t "${IMAGE_NAME}:latest" \ + --push . + diff --git a/scripts/check.sh b/scripts/check.sh index acbd10d..85e743d 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -3,7 +3,7 @@ set -o errexit set -o pipefail -./bin/golangci-lint run +./bin/golangci-lint run --timeout=5m # ./bin/golangci-lint \ # --tests \