From d48702b6c96cc42018bd896370361e7c106c9289 Mon Sep 17 00:00:00 2001 From: Nick Hobart Date: Fri, 31 Mar 2023 15:31:43 -0700 Subject: [PATCH] Fix/update docker GitHub action (#5) * fix: trying a new gha workflow * fix: semantic release badge fix --- .github/workflows/dockerbuild.yaml | 82 +++++++++++++++++++++--------- README.md | 2 +- 2 files changed, 58 insertions(+), 26 deletions(-) diff --git a/.github/workflows/dockerbuild.yaml b/.github/workflows/dockerbuild.yaml index c4905df..7ea99e7 100644 --- a/.github/workflows/dockerbuild.yaml +++ b/.github/workflows/dockerbuild.yaml @@ -1,36 +1,68 @@ -name: Docker Build and Push +name: Docker Build and Publish on: push: branches: - - main + - 'main' + tags: + - 'v*.*.*' + jobs: - build-and-push: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/nucleuscloud/operator + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=semver,pattern={{raw}} + type=sha + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: set up QEMU - uses: docker/setup-qemu-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - - name: Build and Push Docker Image - uses: docker/build-push-action@v4 - with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - provenance: false - tags: | - ghcr.io/${{ github.repository_owner }}/pvb:latest - cache-from: type=registry,ref=${{ github.repository_owner }}/pvb:latest - cache-to: type=inline \ No newline at end of file + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache \ No newline at end of file diff --git a/README.md b/README.md index 8625a70..d1fb8e3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![CodeQL](https://github.com/nwhobart/pvb/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/nwhobart/pvb/actions/workflows/github-code-scanning/codeql) [![Lint](https://github.com/nwhobart/pvb/actions/workflows/ci_workflow.yaml/badge.svg)](https://github.com/nwhobart/pvb/actions/workflows/ci_workflow.yaml) -[![Semantic Release](https://github.com/nwhobart/pvb/actions/workflows/cd.yaml/badge.svg?branch=main)](https://github.com/nwhobart/pvb/actions/workflows/cd.yaml) +[![Semantic Release](https://github.com/nwhobart/pvb/actions/workflows/release.yaml/badge.svg)](https://github.com/nwhobart/pvb/actions/workflows/release.yaml) # pvb Posting Terraform provider versions to a Slack channel